Skip to content
StackDecode
System Design
20. System Design Case StudiesAnimated

URL Shortener (Bitly)

Turn long links into short codes and redirect.

The idea

Generate a unique short code, store the mapping, and redirect fast using a cache.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

ClientAPI serversCacheKey-value storeID generator
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Create: get a unique id (base-62 counter), store id to long URL.

step:
1/4
at:
Client
1/14

The green dot is a request moving through the system.

Step by step

  1. 1Receive a long URL
  2. 2Generate a unique short code
  3. 3Store the mapping
  4. 4On visit look up in cache and redirect

Where it is used

A classic design exercise.

Watch out for

Read-heavy, so cache hot links and avoid code collisions.

Related