High-level design:
- Load balancer → Application servers → Database
- Cache (Redis) between app servers and database
Database schema:
url_mappings: short_code (PK), long_url, created_at, expires_at
Short code generation options:
Hash the URL, take first chars. Collision handling needed.
Pre-generate codes, assign from a pool. No collisions.
Distributed ID generator, convert to base62.
Flow: Client → LB → App Server → Check cache → If miss, check DB → Return redirect.