Load balancing your microservice using Nginx and Consul
So far we have learned how to load balance our microservice using Zookeeper and Consul. Both of these approaches come with their own merits and demerits. The Zookeeper approach required us to write a lot of code, and there is still a possibility of race condition where our proxy controller could invoke a service that just went down. The Spring Cloud Consul approach required us to write the proxy controller. In fact, in both these approaches we had to write our own load balancer microservice. This might not be a scalable approach when you have hundreds of microservices and tons of APIs. That is where HTTP servers such as Apache HTTP Server and Nginx come to the rescue. Nginx is one of the most popular HTTP servers. We could potentially use Nginx as our proxy server to geolocation microservices in a round robin fashion. In this recipe we will learn how to use Nginx and Consul together to load balance our geolocation microservice.