The solution : Consistent hashing (CH)
How does CH work ?
CH facilitates the distribution of data across a set of nodes (DB servers) in such a way that minimizes the mapping or reorganization of data when nodes are added or removed.
1- What is CH ? Creating th Hash Key Space.
We need to consider a hash function that generates integer hash values in the following range [0, 2^32-1] and the output of a hash function is: x0, x1, x2,…,xN.

2- Representing the hash space as a hash ring
By connecting both ends, we get a hash ring. So, we can visualize it as a ring.

3- Hash servers : Placing DB servers in the hash ring
We can use the hash function and so, hash the servers on their IP address to map them to different integers.

4- Hash Keys: Determining placement of keys on servers
To find which DB server an incoming key resides on : we assume we have 4 incoming keys (key0, key1, key2, key3) and none of them directly maps the hash value of any 4 servers on our ring. We follow the hand of a clock and insert the key.

5- Adding a server in the ring
When we add a server, we need to add it between server 0 and server 3. We'll need to remap only to remap the keys to the server 4 (new server).
So, we need to remap only k/n keys where k is the number of keys (4) and n is the number of servers (5).

6- Removing a server from the ring
A server might go down and our consistent hashing scheme ensures that it has minimal effect on the number of keys and servers affected. If server 0 goes down, only the keys between server 3 and server 0 will need to be remapped to server 1 : here, we have 2 keys to consider and the rest of the keys are unaffected.
