Try
↑ ↓ move↵ openesc close

Interview prep / URL shortener

Mid · URL shortener · System design interview question

How do counter ranges let many servers make codes without a central bottleneck?

Sketch your own answer first, then compare it with the one below.

A strong answer

A coordinator hands each creation server a block of numbers, for example a million at a time. The server uses the block alone and writes each number in base 62. It asks for a new block when the old one runs out.

Coordination happens once per block, not once per link. The blocks must never overlap, so the coordinator needs durable state or a lease. A crash wastes the rest of a block, which is harmless.

The downside is that codes are sequential and guessable. A reversible scramble hides the order without making it secret.

Sources

Learn it by running it

The design a url shortener lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms