URL Shortener System Design

Easy
read-heavy
low latency

Turn long URLs into short codes and redirect visitors fast.

About this problem

Design a URL shortening service like Bitly or TinyURL. Anyone can paste in a long URL and get back a short code. Anyone who opens that short link is sent straight to the original page.

Each code must be unique: two links can never share a code, and a code never changes or points somewhere new once it's issued. Redirects have to feel instant, because every click waits on them.

Traffic is lopsided. For every new link there are about 100 redirects, and the load ramps from almost nothing up to 5,000 requests per second, then holds at that peak.

Requirements

  • Create a short code for a long URL.
  • Redirect a short code to its original URL.
  • Codes never collide and never change once issued.

Scale targets

  • Roughly 100 redirects for every new link.
  • Traffic ramps from zero to 5,000 TPS, then holds at peak.

Traffic

Ramp, 50 to 5,000 TPS. The simulator sets this traffic up for you when you start the problem.

CAP trade-off

Favors availability

A redirect that fails breaks every link that uses the service. Codes never change once issued, so serving one a moment late does no harm, but refusing to serve it does.

Practice it

Build it on the canvas, run the traffic, and get scored.