You are here

How to Scale Microservice APIs With Kubernetes and Google Cloud Engine

Microservices are an architectural approach for building distributed software systems, and the concept extends to APIs as well. Microservices-based APIs allow teams to focus on building small and independent components for executing one particular API call, rather than perform an individual service as in a typical microservices implementation.

Since each component is independent, each endpoint can be written in a different language and you can offer a range of SLAs. Each microservice can even be scaled independently, and this tutorial by Sandeep Dinesh on the Google Cloud Platform Blog shows followers how to create a scalable API with microservices using Google Cloud Engine and container scheduling and management service Kubernetes.

Firstly, followers must create a Kubernetes cluster and containerize the code using Docker with individual Dockerfiles for Ruby, Python, Node.js, and Go. Once these containers are deployed to the cloud, create a Kubernetes service for each microservice and then leverage NGINX to proxy those microservices and expose them to the outside world as a single endpoint.

The author then creates internal services and explains the configuration of NGINX and how to expose it publicly before using the public API to test the unified API endpoint. The scaling of the microservice is added at the end, providing several simple commands for easily scaling the number of different containers, and turning on autoscaling to maintain around 80% CPU utilization on each container.

All code is provided, and there is additional reading covering updating and monitoring of your microservice.

Be sure to read the next API Design article: How to Use the cURL Command to Examine the Contents of a Web API's Header

Original Article

Creating a scalable API with microservices

 

Comments