Interviewer picked this one and I could tell it was the easier path.
Start by clarifying requirements and scale (e.g., read/write ratio, expected QPS, latency, storage). Then propose a high-level design with key components like ID generation, database, cache, and API, and dive into trade-offs for each component. Finally, discuss scaling strategies and potential bottlenecks.
Pro tip: At Uber, URL shortening might be used for internal links or promotions, so emphasize reliability, low latency, and analytics. Mention how you'd handle custom aliases and expiration, as these are common in production systems.
Ask about scale (e.g., 100M URLs, 1000 QPS), read/write ratio, latency requirements, and features like custom aliases, expiration, and analytics.
Outline components: API servers, ID generator, database, cache, and analytics. Sketch the flow from URL submission to redirection.
Discuss ID generation (e.g., base62 encoding of auto-increment or distributed ID), database choice (SQL vs NoSQL), and caching strategy (e.g., Redis).
Address scaling: sharding, replication, CDN for redirects, and trade-offs like consistency vs availability, latency vs storage.
Summarize potential bottlenecks (e.g., ID generation, database writes) and suggest improvements like rate limiting, analytics pipeline, and custom alias handling.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.