Design a URL shortener: background and sizing
Application background
A marketing team wants to put go.example/launch on a poster instead of a long campaign address. A creator supplies the long address and asks the service to reserve the short name launch.
When someone opens the short link, the service tells their browser to visit the stored destination. That HTTP response is called a redirect. The difficult cases are two creators requesting the same name and a link that must stop working after publication.
Example walkthrough
01 · Try this input
- Input / starting state
- Creator A requests
launchfor campaign A - Expected result
- Reserve the name and return the short URL.
02 · Try this input
- Input / starting state
- Creator B requests
launchfor campaign B - Expected result
- Report that the name is already taken.
03 · Try this input
- Input / starting state
- An operator blocks campaign A's link
- Expected result
- New visits must stop redirecting to it.
The stored name-to-destination record decides who owns an alias. A fast cached copy must not keep a blocked link usable indefinitely.
Sizing that affects this decision
30 million creations/day is roughly 300 requests/s (RPS) using 100,000 seconds/day, or 347 RPS using the exact day length. Three billion redirects/day is about 34,722 RPS, with an 80,000 RPS hot-campaign case. Separating creation from redirects matters because their traffic and latency needs differ.
These are exercise assumptions. The estimation reference explains the units and approximations. They do not establish the local demo's measured capacity.