#systemdesign#ConsistentHashing
Does load balancer use hashing?
Hashing is one of the common methods used in Load Balancing for distributing requests among the web servers.
How load balancer uses hashing?
We have something known as request_id that is uniquely and randomly generated. Each request by the client is uniquely identified by this request_id. Load balancer hashes the request_id with the proper hash function and distributes the requests.
But here comes the problem, if one server is added or removed from the pool of servers, we need to rehash all requests from the start and distribute them to the servers. So we can use the Consistent Hashing technique to solve this problem.
What is Consistent Hashing?
Consistent Hashing is a distributed hashing scheme that operates independently of the number of servers in a distributed hash table by assigning them a position on hash ring.
For ex, if the hash function(request_id) gives 3 as the hash value, it will be allocated to the server in clock-wise direction. Here it goes to S2. By doing this consistent hashing technique,we can reduce the number of requests that need to be rehased if 1 server added or removed
• • •
Missing some Tweet in this thread? You can try to
force a refresh
#systemdesign
What is CAP theorem?
CAP stands for Consistency, Availability, and Partition tolerance. The theorem states that you cannot achieve all the properties at the best level in a single database.
But we can only pick two out of three at a time and that totally depends on our prioritize based on requirements.
What is Data Consistency?
Consistency means that any read request will return the most recent write.