Design a URL Shortener
Design a globally available URL shortener. Cover requirements, capacity estimates, identifiers, storage, caching, abuse controls, and failure modes.
Examples
Compare approaches
Baseline approach
Begin by explaining the core mechanism, stating assumptions, and walking through one concrete example.
Time: Depends on design · Space: Depends on design
// Use this space for API contracts and architecture notes.
Strong answer
Separate redirect reads from link creation. Use collision-safe identifiers, a durable key-value mapping, caching with an explicit freshness policy, and rate limits. Explain consistency and regional failure trade-offs.
Time: Discuss operation costs · Space: Discuss retained state
// Use this space for API contracts and architecture notes.
Common traps
- Caching redirects indefinitely makes link deletion and abuse takedowns difficult.
- State assumptions and justify trade-offs rather than memorizing a single answer.