System Design · Senior · Question 18 of 75

How do you generate short links in a URL shortener?

Explanation

Base62 of a 64-bit id gives a short string without collisions; the counter is handed out in ranges so nodes don't sync on every request. Random short strings require collision checks; a full hash is too long. Reads are cached, and the redirect is 301 or 302 depending on whether analytics is needed.

Further reading

Problem with a question

System Design · Senior · question 18

Test yourself

Take the System Design · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz