Load balancing your microservice using Spring Cloud Consul
So far in this chapter, we've learned how to set up Consul and then learned how to implement service discovery in Consul using Spring Cloud Consul. Now, your other services can discover the geolocation service with the help of Consul. Earlier, we talked about how significant load balancing is and how we can do it using Zookeeper. In this recipe, we will learn how to perform load balancing using Consul with the help of Spring Cloud Consul.
Getting ready
There may be scenarios where one microservice would want to invoke another microservice's REST API. What if the target microservice is load-balanced using Consul? That is exactly what we are going to demonstrate in this recipe. We will be writing a new microservice called geolocation-consul-lb
that will load balance against two instances of geolocation microservice in a round-robin fashion. When you move away from a monolithic application to more focused microservices, you will end up...