System Design Fundamentals · System design problem
Design a URL Shortener
A free system design problem from the Design a URL Shortener skill. Read it here, then solve it in the app.
- Medium
- System design problem
- Free
The problem
Your task
Design the backend of a URL shortener. Add components from the palette, connect them with arrows from the caller to what it calls (mark an arrow async when the caller hands work off instead of waiting), set how many instances of each run, and write your key decisions in each component's notes - how the cache evicts, how codes are generated, how the database fails over.
When you submit, the design is checked against the requirements below. Before that, use Simulate failure to see what stops working when a component goes down.
Functional requirements
- Create: a signed-in user submits a long URL (optionally a custom alias) and gets a short link
such as
sho.rt/aZ3kQ9. - Redirect: anyone who opens a short link is sent to its long URL.
- Analytics: a link's owner sees clicks per day. Counts may lag by up to a minute.
Scale and quality requirements
| New links | 100 million a month - about 40 writes/s, peaks of 400/s |
| Redirects | 10 billion a month - about 4,000/s, peaks of 40,000/s; a few links get most of the traffic |
| Retention | 5 years - about 6 billion links, roughly 3 TB |
| Redirect latency | p99 under 50 ms |
| Availability | Redirects keep working when any one server, cache node or database node fails |
| Codes | 6-7 characters, never reused, and not trivially guessable for private links |
Capacity. Size your app server tier (the service that answers redirects): in its details, give the requests per second one instance can handle and how many instances run. Together they must cover the 40,000 redirects a second at peak. Use numbers you could defend in an interview - a single instance has limits, so scale out rather than up.
How it's graded
- Draw your architecture on a canvas: typed components, sync or async calls, instance counts and capacity estimates. Submit checks it against rules that follow from the brief, explains every failure, and shows a reference design.
- Stuck? Hints come in four steps, from a nudge to a code skeleton, each costing part of the points.
Draw your design Design a URL Shortener free
No card needed. Lessons, practice questions and easy problems are free forever.
Free plan, no card · 7-day Pro trial · Cancel anytime