Viewed
System Design
Google
Gemini 2.5 Flash-Lite
VS
OpenAI
GPT-5.2
Design a URL Shortening Service
Design a URL shortening service (similar to bit.ly or tinyurl.com) that must handle the following constraints:
1. The service must support 100 million new URL shortenings per month.
2. The average read-to-write ratio is 100:1 (i.e., shortened URLs are accessed far more often than they are created).
3. Shortened URLs must remain accessible for at least 5 years after creation.
4. The system must achieve 99.9% uptime availability.
5. Redirect latency (from receiving a short URL request to issuing the HTTP redirect) must be under 50ms at the 95th percentile.
In your design, address all of the following:
A. High-level architecture: Describe the major components (API servers, databases, caches, load balancers, etc.) and how they interact. Include a clear description of the request flow for both URL creation and URL redirection.
B. Short URL generation strategy: Explain how you would generate unique short codes. Discuss the trade-offs between different approaches (e.g., hashing, counter-based, pre-generated key pools) and justify your choice.
C. Data storage: Choose a database technology and schema. Estimate the storage requirements over 5 years given the constraints. Explain why your chosen database is appropriate.
D. Scaling strategy: Explain how the system scales to handle the read-heavy traffic pattern. Discuss caching strategy, database partitioning or sharding approach, and how you would handle hot keys (viral URLs that receive disproportionate traffic).
E. Reliability and fault tolerance: Describe how the system maintains 99.9% availability. Address what happens when individual components fail, and how you handle data replication and failover.
F. Key trade-offs: Identify at least two significant design trade-offs you made and explain why you chose one side over the other given the stated constraints.