Walk me through how you would design a URL shortener that handles 10,000 requests per second.
Write your answer first
Saved on this device only — nothing is uploaded.
Reveal model answer & level guide
I would size it before designing it. At 10,000 requests per second the traffic is overwhelmingly reads, so the redirect has to be the fast path. I would generate the short key from a counter encoded in base62 rather than hashing the URL and then handling collisions, keep the mapping in a key-value store, and put a cache in front of the redirect. The strongest answers say what they would do about hot keys, and what happens to the database when a popular key expires and every request misses the cache at once.
- Entry
- Reach a working design: how keys are generated, where they are stored, and what happens on a redirect.
- Mid
- Put numbers on it. State the read-to-write ratio, why base62 over a UUID, how much storage a year costs you, and where the cache sits.
- Senior
- Name what breaks first at that rate and how you would know — hot keys, a stampede when a popular entry expires, the ID generator becoming the contended path — and say what you would shard or precompute.