System Design

URL Shortener: Pre-Generated Keys Architecture

System Design diagram · made in Skemio

System architecture showing client requests routed via a load balancer to a URL Service, backed by a Key Generation Service, Redis cache, and database.
System architecture showing client requests routed via a load balancer to a URL Service, backed by a Key Generation Service, Redis cache, and database.

What it shows

  • Hashing URLs risks collisions and expensive retry loops under heavy load.
  • A Key Generation Service creates 7-char keys asynchronously before writes.
  • Reads hit Redis caches first, resolving redirects in under 2 milliseconds.

The takeaway

Don't compute keys on write requests. Pre-generate and consume them atomically.

More system design diagrams