Caching: Cache hot URLs in Redis. % of URLs serve % of redirects. % cache hit rate is achievable.
Database choice: SQL (PostgreSQL) works fine at this scale. TB is manageable.
Scaling: Read replicas for read traffic. Sharding by short_code if needed later.
Trade-offs:
- Hash-based codes: deterministic, but same URL = same code (is that desired?)
- Counter-based codes: sequential, potentially guessable
- Random codes: unpredictable, requires collision checking
Availability: Multiple app servers, database replicas, multi-region if global.