URL Shortener
Turn long links into short codes — and survive the read storm.
Keep redirects fast and always-on while a link goes viral and the datastore fails.
Reads outnumber writes ~100:1. The redirect path must survive a datastore outage — only a high cache/edge hit ratio makes a DB blip a non-event.
Components in play
- Edge CDN — Serves the hottest short codes from the edge.
- Redirect API — Looks up code → URL and 301s.
- Hot-link cache — Absorbs reads so the DB stays idle.
- Key-value store — Source of truth for the mappings.
Graded on these SLOs
- ≥ 99.00%Redirects succeed
- ≤ 110 msRedirect p99
- ≥ 4.0k rpsSustain the reads
- ≤ 6Lean footprint
The brief
Design a service like TinyURL or bit.ly. Users paste a long URL and get a short code; visiting the short code redirects them. Reads (redirects) vastly outnumber writes (creates) — roughly 100:1 — so the redirect path has to be cheap and always-on.
Functional
- Create a short code for a long URL
- Redirect a short code to its long URL
- Optional custom alias
Non-functional
- Read-heavy (~100:1), redirects must be low-latency
- High availability — a dead redirect path is a dead product
- Codes are short and unique
Read the deep dive
16 min readA URL shortener looks trivial: store a mapping from a short code to a long URL, and redirect on lookup. That is exactly why it is a favorite warm-up in FAANG interviews. The interesting engineering is not the data model, which is a single key-value row, but the traffic shape. Redirects outnumber creates by roughly 100 to 1, and the redirect path sits in the critical path of every shared link on the internet. A dead redirect path is a dead product, so the whole design problem is really about making reads cheap, fast, and resilient to the datastore going dark. This guide walks you to the reference architecture the SysGym simulator grades you against. The scenario starts at 4,000 redirects per second, ramps toward a 3x peak of 12,000 rps as a celebrity shares a link, drops the datastore as that surge hits, and then lets the store limp back with an 8x latency spike. Your job is to keep redirects succeeding at 99% availability with a sustained p99 at or below 110 ms while spending a lean footprint. We will derive every component and every number from first principles, then map them back to the exact SLOs and the reference graph so the article and the gym reinforce each other.
Warm-up: design decisions
Optional theory to prime the calls a senior engineer would make before you build.
Run first, save progress later
The simulator is open without an account. Create one after your run to reveal the score, take the quiz and keep your progress.
- AI design coach on your canvas — pins failure points & over-engineering
- Honest AI design review on every run
- All 12 problems + unlimited chaos simulator
- Points, levels & leaderboard