failover
← All labs

Easy · 12 steps · ~60 min

Design a link shortener

Billions of redirects, a few writes, and short codes that never collide.

A link shortener turns a long address into a short code, then sends anyone who opens the code to the original page. Creating links is rare; opening them is constant.

Same problem as BitlyTinyURLt.co

How it works

What you'll build

  1. The API and the data behind it
  2. A system that answers 500 requests a second
  3. A cache, replicas and a load balancer for 50,000
  4. A rate limiter that stops a scraper
  5. A design that survives a cache restart, a lost server and a lost primary

Steps

  1. 1Design the API
  2. 2Design the data model
  3. 3Handle 500 requests/sec
  4. 4Handle 15,000 requests/sec for $1,000 a month
  5. 5Handle 50,000 requests/sec
  6. 6Handle 50,000 requests/sec for $1,700 a month
  7. 7Survive a scraper on the same budget
  8. 8Survive a cache restart
  9. 9Lose an API server
  10. 10Lose the primary database
  11. 11New links 404 for their creators
  12. 12Deep dive: generating short codes
Start the lab →