diff --git a/README.md b/README.md index f2285f36..29cc8880 100644 --- a/README.md +++ b/README.md @@ -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: + +* Hash Ring: 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. + +* Request Distribution: 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. + +* Scalability and Consistency: 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 + +

+ +
+

+ ### 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. diff --git a/images/jsjss.png b/images/jsjss.png new file mode 100644 index 00000000..f0b82534 Binary files /dev/null and b/images/jsjss.png differ