Consistent Hashing - in simple words

Imagine you're running a big website, and lots of people are visiting it every day. To handle this traffic, you have multiple servers. Now, you want to distribute the load of incoming requests among these servers efficiently.

Consistent hashing is a technique that helps you do this. Instead of assigning each request to a server randomly or based on some fixed rule, consistent hashing uses a special algorithm. Here's how it works in simple terms:

Imagine a Circle: Think of all your servers arranged in a circle. This circle has numerical values like a clock, ranging from 0 to 360 degrees.

Mapping Requests: When a request comes in, consistent hashing uses this circle to quickly figure out which server should handle the request. It calculates the position of the request on the circle using a similar method, creating a numerical value.

Finding the Closest Server: Then, it finds the nearest server in a clockwise direction on the circle. This server is the one that will handle the request. Even if a server is added or removed, only the requests near that change need to be reassigned. Most of the existing assignments stay the same.

In essence, consistent hashing is a smart way of evenly distributing the requests among servers, ensuring a balanced load, and making it easy to add or remove servers without completely changing how requests are distributed. It's like a clever way of ensuring fairness and efficiency in managing lots of incoming data or requests!