Skip to content

A URL shortener like bit.ly

Design a URL Shortener, from a blank page

This is how the interview actually runs: one prompt, and you decide what to cover and in what order. Write each section, then compare it with a reference design and see what you left out.

A 45-minute round. You drive; nothing prompts you.

The prompt

A marketing-tools company offers short links. A customer pastes a long URL and gets back something like sho.rt/aZ3kQ9x to put in emails, posters and social posts. The customer can see how many clicks each link got, by day and by country.

They expect about 100 million new links a month and 10 billion redirects a month. Big campaigns push traffic to about five times the average. People click from all over the world, but the servers are in one US region today. Occasionally a link turns out to point at malware, and the trust-and-safety team needs it switched off immediately.

What the interviewer would tell you if you asked
  • About 100 million new links a month and 10 billion redirects a month, with peaks around 5× average.
  • Links never expire unless the customer deletes them.
  • One region today, Postgres as the primary database, a CDN available.
  • Clicks are very uneven: a small fraction of links gets most of the clicks.
  • Customers may change a link's destination after creating it.
  • Click counts may lag by a minute or two.
0:00of 45 min
0 of 5 sections written
  1. 01

    about 5 min

    What does the system have to do, and how well? List the functional requirements, then the non-functional ones (latency, availability, consistency, scale), and the questions you would ask the interviewer.

  2. 02

    about 5 min

    Turn the volumes into the numbers that drive the design: requests per second at peak, storage, bandwidth, and anything else that decides whether one machine is enough.

  3. 03

    about 10 min

    Name the components and what each one is responsible for. Then trace the main request through them, and say where the durable state lives.

  4. 04

    about 15 min

    Pick the hardest decisions in this design and make them: what you chose, what you rejected, and which constraint decided it.

  5. 05

    about 10 min

    What breaks? Walk through crashes, duplicates, slow dependencies and overload, and what the design does in each. Then: what changes at ten times the load, or with a new requirement?

Write something in at least 3 sections first. Gaps are fine; the comparison shows what they cost.