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 & Difficulty | Read-Heavy & Caching · EASY |
|---|---|
| Traffic Profile | 20,000 RPS sustained, 26,000 RPS spike (99% reads / 1% writes) |
| Latency & Availability SLA | p99 < 50 ms · 99.99% availability |
| Monthly Infra Budget | $350/month |
| Commonly Asked At | Google, 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):
- 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
Caching reads: cache-aside and hit rate
Put a cache in front of a database and work out how much load it really takes off.
Hot keys and partitioning
Split data across nodes with a good key, and spot one key taking all the load.
Ledgers and holds: never oversell
Record money as entries that add up, and reserve stock without overselling.
Related Read-Heavy & Caching problems
Real-time Activity Feed
Serve home timeline feeds for 30,000 peak requests/sec (90% reads). Ensure p99 latency stays under 200ms with 99.9% availability.
E-Commerce Search & Catalog
Serve high-traffic product catalog queries for 15,000 peak RPS (95% reads). Maintain p99 latency under 80ms while protecting database IOPS.
Design Pastebin Text Sharing
Design a text-sharing service like Pastebin handling 15,000 read RPS and 1,500 write RPS. Store text payloads in Object Storage while querying metadata rapidly with low latency.
Design Key-Value Store
Design Key-Value Store: Architect a scalable, highly-available distributed system capable of sustaining 25,000 peak RPS (80% reads). Maintain p99 latency under 80ms with 99.9% availability while optimizing monthly infrastructure cost within $600/mo.