Design a URL Shortener
Design a service that turns long URLs into short links and redirects visitors to the original URL.
Like bit.ly or TinyURL · Easy
Functional requirements
- Create a short link for a long URL
- Redirect a short link to the original URL
- Optional custom alias and expiry
Scale & non-functional requirements
- 100M new links per month
- Redirects are 100× more frequent than creates
- Redirect latency under 50 ms
Hints
- How do you generate unique, short IDs without collisions?
- Reads dominate — where does caching help most?
- How would you shard the mapping table?