Problems / Design a product, easy

Build a URL shortener

Design bit.ly from an empty canvas: create short links and redirect them, fast, at 2,000 requests a second.

Free to open. Sign in with Google to start; new accounts get free credits.

What it must do

Scale

Request types to route: redirect (95%, read), shorten (5%, write). Budget: $1,500 a month.

Estimate first

The test cases

You start from an empty canvas. When you run the tests, each one simulates your design with its own traffic and failures:

TestWhat it doesPasses when
Normal dayThe normal day: the traffic in the brief, nothing broken.Success ≥ 99.9%; p99 latency ≤ 100 ms (redirect)
A link goes viralAt 5 s a link goes viral: traffic triples for 8 s.Success ≥ 99%; p99 latency ≤ 250 ms (redirect)
Cache flushedAt 5 s the cache on the request path is emptied, as after a restart or a bad deploy.Success ≥ 99%
A server diesAt 4 s one server of the first app service on the request path dies for 10 s.Success ≥ 99%
Budget: $1,500/monthThe normal day's design must cost at most $1,500 a month.Cost ≤ $1,500/month

Must include

Hints

Try it first. Open one hint at a time if you get stuck.

Hint 1

Start where traffic enters: a load balancer in front of a stateless API.

Hint 2

Redirects are reads of a few hot keys: look them up in a cache first, and go to the database only on a miss.

Hint 3

New links are writes: send them straight to a key-value store keyed by the short code.

Hint 4

Give the API at least 3 replicas so one can die, and size the store for the reads the cache misses.

One way to solve it

Load balancer → API (3–4 replicas) → Redis cache for redirects (miss → key-value store); new links written to the key-value store, optionally with an ID generator for the short code.

More design a product problems