Open In App

Spring Cloud – Difference Between Client Side and Server Side Load Balancer

Last Updated : 16 Jul, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Spring Cloud is a collection of projects like load balancing, service discovery, circuit breakers, routing, micro-proxy, etc will be given by Spring Cloud. So spring Cloud basically provides some of the common tools and techniques and projects to quickly develop some common patterns of the microservices.

What is Load Balancer in Spring Cloud?

Taking about the general definition, Load Balancer is a network device that sits between a set of backend servers and clients. It distributes the incoming traffic to multiple servers to reduce the load. Load Balancers typically use various algorithms, such as round-robin to determine which server to send incoming traffic to. Please refer to the below image and observe how the above problem is fixed by Load Balancer.

 

So, in Spring, if you want to use Load Balancer then Spring Cloud provides us with some already developed ready-made Load Balancer. By using this you don’t need to write any Load Balancer or create your own, you can just use the tool very easily by importing some dependencies and writing minimal code.

Type of Load Balancer

There are two ways to load balance the request

  1. Client-Side Load Balancer
  2. Server-Side Load Balancer

1. Client-Side Load Balancer

If you are keeping the load balancer on the client side and giving the load balancing responsibility to the client, then it’s called Client-Side Load Balancing. In Client-side Load Balancing the instances of the microservice are deployed on several servers. The logic of Load Balancer is part of the client itself and it carries the list of servers and determines to which server a particular request must be directed based on some algorithm.

Client-Side Load Balancer

 

Note: Read more here Spring Cloud – What is Client Side Load Balancer

2. Server-Side Load Balancer

If you are keeping the load balancer on the server side and giving the load balancing responsibility to the server, then it’s called Server-Side Load Balancing. In Server-side load balancing, the instances of the service are deployed on multiple servers and then a load balancer is placed in front of them. Firstly, all the incoming requests come to the load balancer which acts as a middle component. Then it determines to which server a particular request must be directed based on some algorithm.

Server-Side Load Balancer

 

Note: Read more here Spring Cloud – What is Server Side Load Balancer

Client Side Load Balancer vs Server Side Load Balancer

Client Side Load Balancer

Server-Side Load Balancer

If you are keeping the load balancer on the client side and giving the load balancing responsibility to the client, then it’s called Client-Side Load Balancing. If you are keeping the load balancer on the server side and giving the load balancing responsibility to the server, then it’s called Server-Side Load Balancing.
No more single point of failure in Client Side Load Balancer. The main disadvantage of Server-Side Load Balancing is the single point of failure.
Less network latency as the client can directly call the backend servers. Network latency rises in Server-Side Load Balancing.
Cost Reduction as there is no need for server-side load balancing. The cost is high to implement Server-Side Load Balancing in comparison to Client-Side Load Balancing.
In this case, the microservice code is combined with the load balancer’s logic. Since each microservice will have a particular load balancer, the complexity of the system rises and it is hard to manage.
Client-Side Load Balancer Provided by Spring Cloud: Spring Cloud Load Balancer, Netflix Ribbon Server-Side Load Balancer Provided by Spring Cloud: Spring Cloud Gateway, Netflix Zuul

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads