What is client Side Load Balancing in Microservice Architecture
In this tutorial we are going to learn about client Side Load Balancing in Microservice Architecture.
Client Side Load Balancing: The client holds the list of server IP addresses. So that it can deliver the requests. The client selects an IP from the list that is fetched from the service registry, randomly, and forwards the request to the server.
Ribbon is a client side IPC library that provides the following features: load balancing, fault tolerance, multiple protocols support in an asynchronous and reactive model, caching and batching.
- No more single point of failure as in the case of the traditional load balancer approach.
- Reduced cost as the need for server-side load balancer goes away.
- Less network latency as the client can directly invoke the backend servers removing an extra hop for the load balancer.
Lets take a simple example of an booking application with a booking service that communicates with the payment gateway and we have multiple instances of payment services up and running.
The payment service connects to the third party applications through rest or rabbitMQ and there is one more service running i.e., account service which holds the user info that may be credit card information or any information related to customer.
Booking service communicates with both the payment service and account service, and account service communicates with the payment service.
Now imagine that these microservice containers are deployed into cloud environnement and to make the application more scalable add the service registry pattern.
All the services up and running must be registered with the service registry. Once all the services are registered and there are multiple instances of payment service running in different machines or containers or pods which is a difficulty in load balancing. So here comes the client side load balancing where booking service directly chooses which service to hit by getting the information required from the service registry.