Add Consistent Hashing Session

pull/886/head
Shafaq Arshad 2024-07-14 17:00:03 +01:00
parent 3df19b2e4f
commit 502c5f3659
2 changed files with 19 additions and 0 deletions

View File

@ -124,6 +124,7 @@ Review the [Contributing Guidelines](CONTRIBUTING.md).
* [Active-active](#active-active)
* [Layer 4 load balancing](#layer-4-load-balancing)
* [Layer 7 load balancing](#layer-7-load-balancing)
* [Consistent Hashing](#consistent-hashing)
* [Horizontal scaling](#horizontal-scaling)
* [Reverse proxy (web server)](#reverse-proxy-web-server)
* [Load balancer vs reverse proxy](#load-balancer-vs-reverse-proxy)
@ -689,6 +690,7 @@ Load balancers can route traffic based on various metrics, including:
* [Round robin or weighted round robin](https://www.g33kinfo.com/info/round-robin-vs-weighted-round-robin-lb)
* [Layer 4](#layer-4-load-balancing)
* [Layer 7](#layer-7-load-balancing)
* Consistent Hashing
### Layer 4 load balancing
@ -700,6 +702,23 @@ Layer 7 load balancers look at the [application layer](#communication) to decide
At the cost of flexibility, layer 4 load balancing requires less time and computing resources than Layer 7, although the performance impact can be minimal on modern commodity hardware.
### Consistent Hashing
Consistent hashing is a technique used in load balancing to distribute requests evenly across multiple servers in a distributed system.
Here's how it works:
* <b>Hash Ring:</b> Imagine a virtual circle, called a hash ring. Each server and each incoming request is assigned a position on this circle based on a hash function. The hash function ensures that the same input (server ID or request data) always gets mapped to the same position on the ring.
* <b>Request Distribution:</b> When a request arrives, its data (often a unique identifier) is hashed to determine its position on the hash ring. The server responsible for handling the request is the one whose position on the ring comes after the hashed request data, continuing clockwise around the circle.
* <b>Scalability and Consistency:</b> The key benefit of consistent hashing is its scalability. If a server is added or removed, only requests that map to the immediate vicinity of the affected server will be re-routed. Most requests will continue to be directed to the same servers as before. This minimizes data re-caching and avoids creating hotspots where certain servers become overloaded
<p align="center">
<img src="images/jsjss.png">
<br/>
</p>
### Horizontal scaling
Load balancers can also help with horizontal scaling, improving performance and availability. Scaling out using commodity machines is more cost efficient and results in higher availability than scaling up a single server on more expensive hardware, called **Vertical Scaling**. It is also easier to hire for talent working on commodity hardware than it is for specialized enterprise systems.

BIN
images/jsjss.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB