Design a URL Shortener – mid-level system design challenge

Redirect traffic grows from 1,000 to 20,000 requests per second. Keep every redirect fast through a cache restart and a server failure at peak, within budget.

Requirements

Goal

Hold p99 latency under 150ms, error rate under 0.5%, cost under $5,000/month through every stage of the test plan, then compare your design with a reference design.

The test plan

  1. Launch: 1,000 requests per second.
  2. Growth: 5,000 requests per second.
  3. Peak: 20,000 requests per second.
  4. Cache restart: the cache restarts empty at 5,000 requests per second.
  5. Server lost at peak: one API server instance fails at 20,000 requests per second.

Hint

Reads outnumber writes 100 to 1, so a cache in front of the database is the whole game. Put the API servers behind a load balancer with room to lose one, and give the database enough read replicas to survive the cache restarting. Check what a CDN would cost before adding one.

Solve it on the live simulator, free and in your browser.

Read the guide

More system design challenges