diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/README-zh-TW.md b/README-zh-TW.md index c08f740d..fa348ff0 100644 --- a/README-zh-TW.md +++ b/README-zh-TW.md @@ -545,7 +545,7 @@ DNS 是階層式的架構,一部分的 DNS 伺服器位於頂層,當查詢 [CloudFlare](https://www.cloudflare.com/dns/) 和 [Route 53](https://aws.amazon.com/route53/) 提供了 DNS 的服務。而這些 DNS 服務商透過以下幾種方式來決定流量如何被分派: -* [加權輪詢](http://g33kinfo.com/info/archives/2657) +* [加權輪詢](https://www.jscape.com/blog/load-balancing-algorithms) * 防止流量進入正在維修中的伺服器 * 在不同大小的集群中進行負載平衡 * A/B 測試 diff --git a/README.md b/README.md index 90d2a6ac..8a11af04 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 + +
+
+
+