Load balancing
What is load balancing ?
As the name suggest this technique is used in distributing the load.
Why it is used ?
In any high available scalable application it will be deployed in multiple servers and load balancing techniques are used for providing failover support.
Where it is used ?
Load balancing sits in front of multiple servers and uses routing algorithms like round robin for distributing the load.
How it is used ?
Load balancing can be used in the following kinds
- Hardware
- Software
Examples
- Between front end clients and backend servers.
- Between webservers and applications.
- Between application servers and database servers.
- Between application servers and cache layers.
Types of load balancers.
- Smart clients
As the name suggest, load balancing techniques are used in client itself and also it will check for health and status of the backend servers.
It is good for small solutions.
Example
Clients can be mobile or application that can pick and route to any servers by detecting its health and status.
Problems
1. It will be very hard for scaling large scale applications.
2. It will be very hard to maintain.
2. Hardware
As the name suggest, hardware is used
Advantages
Extremely scalable and available.
Problems
1. It is costly.
2. Hard to configure.
Example : Citrix Netscaler
3. Software
As the name suggest, software is used.
Advantages
1. Pre built only configuration required
2. It can be installed on both linux and windows servers
3. Cost effective.
4. Provides some addon functionalities like HTTP caching.
Example : Haproxy
Load balancing techniques are used for handling the following kinds of traffics
- HTTP – Typical web server traffic.
- HTTPS – Similar to HTTP in addition with encryption.
- UDP – core internet protocols
- TCP – Request to database
How does the load balancing route the requests ?
- It uses different strategies for routing such as
1. Round Robbing
2. Weighted Distribution
3. Sticky session
2. Load balancing also health checks the backend servers and transfers the request to the active backend server for providing high availability and to avoid data loss.
Strategies in detail
- Round Robbing
In this load balancer will transfer request to the active backend servers equally across active servers without considering the hardware capability.
2. Weighted Distribution
In this load balancing will transfer request to the active backend servers based on hardware capability
3. Sticky session
In this load balancing will transfer request to the active backend servers based on sticky session
Images are drawn using draw.io and open sourced in github
Github - https://github.com/divagartech/system-design/tree/master/Load%20balancing
Developer | Mentor | Lead at Zoho Corporation
5 年Divagar carlmarx include routing based on url and cookies routing as well