Load balancing microservices using Zookeeper
In the previous recipe, we orchestrated a Zookeeper instance along with an Exhibitor instance. In this recipe, we will utilize these instances to load-balance the geolocation microservice. We will be spinning off two instances of the geolocation microservice and see how we can use Zookeeper and the Curator API to perform round-robin style load balancing on the HTTP endpoints exposed by the geolocation microservice.
Load-balancing HTTP-based microservices is a significant step towards onboarding your microservice to a cluster such as Mesos or Kubernetes. Scalability will not have any value unless you figure out a way to load-balance your microservices. Zookeeper is just one way to do this; with the tools currently available, there are several ways to do this: using frameworks such as Consul and Marathon LB (Mesos/Marathon specific). In fact, there are libraries that even let you perform load-balancing on the client side. We will be looking at Consul...