DesignTheSystem/dev
EASY Read-Heavy & Caching Asked at Google, Amazon, Microsoft

Design High-Volume URL Shortener

Design a URL shortening service handling 20,000 peak requests/sec with a 99:1 Read/Write ratio. Keep p99 latency under 50ms with 99.99% availability.

Category & DifficultyRead-Heavy & Caching · EASY
Traffic Profile20,000 RPS sustained, 26,000 RPS spike (99% reads / 1% writes)
Latency & Availability SLAp99 < 50 ms · 99.99% availability
Monthly Infra Budget$350/month
Commonly Asked AtGoogle, Amazon, Microsoft, Meta

Scale, traffic & SLA targets

To pass in the DesignTheSystem simulator, your architecture must hold all four targets simultaneously across a 60-second load run (spiking up to 26,000 RPS):

Peak traffic20,000 RPS99% reads / 1% writes
Latency (p99)< 50 ms99th percentile target
Availability99.99%Max error rate 0.01%
Monthly budget$350/moPriced per component
  • Links (About 100M a year): About 500 bytes each: roughly 50 GB a year of link records.
  • Code length (7 characters): 62^7 is about 3.5 trillion codes, enough for centuries at this rate.

Functional & non-functional requirements

Functional scope

  • Turn a long URL into a short code.
  • Redirect a short code to its long URL.
  • Optional custom aliases and expiry dates.

Non-functional goals

  • p99 latency under 50 ms at the spike.
  • At least 99.99% of requests answered.
  • Costs no more than $350 a month.
  • Redirects must not fail: a broken short link is a broken link everywhere it was shared.
  • Codes should not be easy to guess in sequence.

Core challenge: Redirects are read again and again

A short link is created once and opened thousands of times, and it never changes. That makes it perfect for a cache: keep popular links in memory and only ask the database on a miss.

What breaks first?

Take a unique 64-bit id from a sequence or an id service (like Snowflake), and write it in base 62 (0-9, a-z, A-Z). Unique ids give unique codes, so there are no collisions to check for. If codes must not be guessable, shuffle the id with a reversible mix before encoding.

Key architectural trade-offs

  • 301 redirects are cheaper but you lose click counts; 302 costs a request per click but you see every one.
  • A cached link that is deleted or changed must be removed from the cache too.

Starting architecture & how to practise

The simulator starts you with a baseline setup: Global Clients → Shortener API Service → PostgreSQL Primary. Run the baseline under 20,000 RPS to watch exactly which component saturates first, then add caching, queues, replicas, sharding or CDN until latency, availability and cost all turn green.

Common interview questions for High-Volume URL Shortener

What are the target SLA and scale numbers for High-Volume URL Shortener?

Design for 20,000 RPS sustained (spiking to 26,000 RPS) with a 99% read / 1% write mix, keeping p99 latency under 50 ms, availability at or above 99.99%, and infrastructure spend within $350/month.

What is the main architectural bottleneck in High-Volume URL Shortener?

A short link is created once and opened thousands of times, and it never changes. That makes it perfect for a cache: keep popular links in memory and only ask the database on a miss.

How can I verify my High-Volume URL Shortener architecture works under load?

Open the live simulator to wire up load balancers, caches, queues, replicas, or shards and run a 60-second traffic simulation that grades latency, error rate, and monthly cost automatically.

Recommended lessons before you build

Related Read-Heavy & Caching problems