Design TinyURL
BeginnerOn the roadmap:Beginner · step 9: Your first designInterview Ready · step 7: Practise under pressure
Build a URL shortening service like bit.ly.
Start with requirements and capacity estimates, then API design, data model, the short-code generation strategy, caching, and finally scaling and failure handling.
Requirements
- Create a short link for a long URL (optionally with a custom alias)
- Redirect short links to the original URL quickly
- Links can expire
- Basic click analytics
Scale & constraints
- 100M new URLs per month
- Read:write ratio of about 100:1
- Redirect p99 latency under 100 ms
- Links are stored for 5 years
Hints (try without them first)
- How do you generate unique short codes? Compare hashing, counters and pre-generated key ranges.
- Which is the hot path, and how do you make it fast?
- How big is the dataset after 5 years? Estimate it.