Consistent hashing is a simple yet powerful solution to a popular problem: how to locate a server in a distributed environment to store or get a value identified by a key, while handle server failures and network change?
A simple method is number the servers from 0 to N – 1. To store or retrieve a value V, we can use Hash(V) % N to get the id of the server.
However, this method does not work well when 1) some servers failed in the network (e.g, N changes) or 2) new machines are added to the server.
How to design a tinyurl service is one of the most popular interview questions. It is often asked in the third or fourth round as the big data design interview question. To master tinyurl design, you need to be familiar with Base Conversion of Numbers, and Consistent Hash algorithm.
So what is tinyutl service? It is a URL service that can provide a map between a shorter and unique url to a long URL provided by a user.
For instance, “http://wp.me/p7Eshi-o3” is the tiny url for the current page. Typically,