Design a URL shortener like bit.ly or TinyURL.
Functional requirements:
- Given a long URL, generate a short URL
- Given a short URL, redirect to the original URL
- Optional: custom short URLs, expiration, analytics
Non-functional requirements:
- Low latency redirects ( ms)
- High availability
- Short URLs should be unpredictable (not sequential)
Scale:
- million URLs created per month
- billion redirects per month (read-heavy, : read:write ratio)