1. Design a URL Shortener
Create short links, resolve them quickly and handle expiry without sending users to the wrong destination.
The brief
Design a URL shortener that creates links and redirects visitors to their original destination. Define the create and redirect contracts, how short codes remain unique, and how expiry and deletion affect cached redirects. Explain one failure from the visitor’s perspective.
- Create 1 million links/day; each link receives 100 redirects on average.
- Redirect traffic peaks at ten times the daily average. Store the destination and owner for one year.
- Owners may expire or delete a link. Custom aliases and detailed analytics are optional follow-ups.
Constraints
- Redirect latency≤ 100 milliseconds
- State a p95 server response target, excluding the destination website and internet transit.
- Unique destinations
- Concurrent creates and retries must not assign one short code to two different destinations.
- Deletion and expiry
- State a bounded delay for invalidating redirects and how clients see expired or deleted links.
What to cover
- 01
API and data model
Define link creation, redirect and deletion responses, identifiers and ownership.
- 02
Read and write paths
Show durable link storage, code allocation and the redirect cache.
- 03
Capacity estimate
Estimate average and peak redirect QPS and one year of storage with stated record size.
- 04
Failure and tradeoff
Trace a duplicate create and a cache outage; compare two ways to allocate codes.
Worked designs
Explore the architecture and decisions, then build on an example with Coach.
Review rubric
AI feedback uses these criteria. Scores are practice feedback.
Identity and API contract
Unique codes, retries and ownership form a consistent create contract.
Redirect correctness
Caches, missing links and deletion obey a stated contract.
Capacity reasoning
Read load and storage estimates support the design.
Failure reasoning
An outage walkthrough and a code-allocation tradeoff are explained.
Discussion
Share an approach, ask a question, or tag @Coach.
Loading discussion…