2. Least Connections
Least connections is a load balancing technique that selects the server with the lowest number of connections to handle new requests. This technique aims to distribute the workload evenly and avoid overloading a particular server.
How it works:
- The load balancer receives a request from the client.
- The load balancer selects the server with the lowest number of connections.
- The load balancer sends a request to the selected server.
- The server processes the request and sends the response to the client.
Excess:
- Distribute workloads evenly between servers.
- Avoid overloading certain servers.
Deficiency:
- A server that has just completed a lot of requests may still have fewer resources than other servers, even though it has fewer connections.
- Does not consider server response time.
Application Example:
- Web applications with dynamic and unpredictable workloads.
- Applications that are sensitive to response times, such as VoIP applications or online games.
3. IP Hash
IP hashing is a load-balancing technique that uses the hash of the client’s IP address to select a server. This technique ensures that all requests from the same client are always directed to the same server, which can improve the performance and stability of the connection.
How it works:
- The load balancer receives a request from the client.
- The load balancer calculates the hash of the client’s IP address.
- The load balancer selects the server based on the hash value.
- The load balancer sends a request to the selected server.
- The server processes the request and sends the response to the client.
Excess:
- Ensures that all requests from the same client are always directed to the same server.
- Improve connection performance and stability.
- Easy to implement.
Deficiency:
- If the selected server fails, all requests from the same client will fail.
- It does not consider the current server workload or server response time.
Application Example:
- A web application with many users who often log in and log out.
- A web application that uses cookies to store session data.
4. Least Response Time
The least response time is a load-balancing technique that selects the server with the shortest response time to handle new requests. This technique aims to provide the best user experience by minimizing waiting time.
How it works:
- Load balancers periodically measure the response time of each server.
- The load balancer receives a request from the client.
- The load balancer selects the server with the shortest response time.
- The load balancer sends a request to the selected server.
- The server processes the request and sends the response to the client.
Excess:
- Provide the best user experience by minimizing wait times.
- Suitable for applications that are sensitive to response time.
Deficiency:
- Requires periodic measurement of server response times, which can increase overhead.
- A server that has just completed a lot of requests may still have a slower response time, even though it has more resources.
Application Example:
- Real-time web applications, such as trading apps or online games.
- Performance-critical web applications, such as e-commerce websites.
5. Weighted Round Robin
Weighted round-robin is a load-balancing technique that combines the round-robin technique with weights for each server. This weight can be determined based on various factors, such as server capacity, server performance, or the type of service provided by the server.
How it works:
- The load balancer receives a request from the client.
- The load balancer selects the next server in the list in order, taking into account the weight of each server.
- The load balancer sends a request to the selected server.
- The server processes the request and sends the response to the client.
Excess:
- Distribute workloads evenly between servers with server capacity and performance in mind.
- Easy to implement and configure.
Deficiency:
- Requires proper weighting for each server.
- Does not consider server response time.
Application Example:
- Web applications with servers that have different capacities and performance.
- Web applications with different types of services, such as static web servers and dynamic web servers.