The Making of a 100% Google Powered Microservice Architecture — Part 1
Microservice architecture has been the rage these days and more people are migrating to it. However, this architecture is very unfamiliar to a lot of people and if it’s not done right, it can introduce more problem than it actually solves. In this series of blog post, I will describe an approach to building microservices leveraging tools and technologies built at Google. This setup promises to be low cost, highly efficient and infinitely scalable. The setup adheres to the reactive manifesto. If you don’t know about the reactive manifesto, go read it now.
We will be building a blog api using microservice architecture and google tools. It will consist of authorization and blog microservice as well as the api-gateway.
This series is broken down into multiple posts which I will be posting gradually. The posts are:
- Part 1: The Language — Golang
- Part 2: The Serializer — Protocol Buffers
- Part 3: The Framework — gRPC
- Part 4: The Data — Cloud Sql Postgres
- Part 5: The Container Orchestrator — Kubernetes & GKE
- Part 7: The API Gateway — Google Cloud Endpoint
- Part 8: The Authentication: Firebase Auth
- Part 9: The Message — Cloud Pub/Sub
- Part 10: The Trace — Stackdriver Trace
- Part 11: The Monitor — Stackdriver Monitoring
- Part 12: The Aggregated Logs — Stackdriver Logging
- Part 13: The Continuous Deployment — Google Cloud Builder
- Part 14: The Uptime Checks & Alerting Policies — Stackdriver Monitoring
- Part 15: The Error Reporting — Stackdriver Error Reporting
The Language — Golang
According to wikipedia
Go (often referred to as golang) is a free and open source programming language created at Google in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is a compiled, statically typed language in the tradition of Algol and C, with garbage collection, limited structural typing, memory safety features and CSP-style concurrent programming features added
Go is compiled and statically typed. It was built as an alternative to C and C++ and hence it’s fast and highly efficient. Unlike C and C++, it simple, safe and developer friendly. It also makes very efficient use of resources since it compiles to binary and doesn’t depend on virtual machines(JVM, Erlang VM, CLR) to run it’s code. This attributes makes it very suitable for building microservices.
Go was designed for scalability and concurrency from the ground up. To achieve this, it uses coroutines called goroutines. A goroutine is a lightweight thread managed by the Go runtime. Communication between goroutines is done very elegantly using channels. With proper use of goroutines and channels, you can scale you load up while using very little resources. Also, the fact that a go program is a simple binary means that we can scale our load easily across multiple machines.
The cost of running a program/service built with golang is very small. This is because Go can compile to binary with zero dependencies. When this is combined with it’s efficient and concurrent attributes, we can do far more will spending less on resources. With Golang, you can deploy services using as low as 10 millicores of CPU and 20mB of RAM. This is definitely not possible with dynamic languages(ruby, python etc) or partially compiled languages(Java, C#, Erlang).
In conclusion, I dare argue that Golang is the perfect language for building microservices and it was developed by Googlers at Google.
In the next post, we will discuss inter-service communication and how we can use protocol buffers to pass data around. Stay tuned.
If you liked this, click the💚 below so other people will see this here on Medium. Also, if you have any question or observation, use the comment section to share your thoughts/questions.