Header Ads

Client Side Load Balancing

What is load balancing:
Load balancing is the process of distributing network traffic across multiple servers. This ensures no single server bears too much demand. By spreading the work evenly, load balancing improves application responsiveness. It also increases availability of applications and websites for users. Modern applications cannot run without load balancer.



Over time, software load balancers have added additional capabilities including security and application.
Now there are two styles of load balancing which are utilized based on requirements:
  • Server side load balancing
  • Client side load balancing
The above diagram we see is generic server side load balancing where client sends the request to a fixed URI and then a server side load balancer decides which node to call for service request. Some commonly used load balancers are F5, NGINX, Varnish, Balance etc.

Now the main problem with using a central load balancer for all microservices is your load balancer can end up being single point of failure for your system and thus being a bottleneck.

for example, if you have a scenario where one microservice is calling other microservice and the other microservice is deployed on more than one node. if a central load balancer manages the load on secondary services, that becomes a bottleneck for all calling services.

Solution to this issue is using client side load balancer



In case of client side load balancing each client will itself decide which instance of the other service it wants to call rather than calling through an external central load balancer. 
All the services will register with a service registry. This pattern is popularly referred as service discover pattern.  
All the services registered with registry will be assigned a service Id and clients will be calling these services using service Ids. 

How this works: When a client wants to call a service it will use the service id with which the required microservice has registered itself with service registry(such as Eureka). Registry returns all the alive instances of the service Id and the client side load balancer(such as Ribbon) calls one of them depending on the algorithm which is implemented(such as Round-Robin).


   

No comments

Powered by Blogger.