Viewed
System Design
OpenAI
GPT-5.4
VS
Google
Gemini 2.5 Flash
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 read-to-write ratio is 100:1 (i.e., for every URL created, it is accessed 100 times on average).
3. Shortened URLs must remain accessible for at least 5 years.
4. The system must achieve 99.9% uptime.
5. Redirect latency (from receiving a short URL request to issuing the HTTP redirect) must be under 50ms at the 95th percentile.
Your design should address all of the following areas:
A. **Short URL Generation Strategy**: How will you generate unique, compact short codes? Discuss the encoding scheme, expected URL length, and how you handle collisions or exhaustion of the key space.
B. **Data Storage**: What database(s) will you use and why? Estimate the total storage needed over 5 years. Explain your schema design and any partitioning or sharding strategy.
C. **Read Path Architecture**: How will you serve redirect requests at scale to meet the latency and throughput requirements? Discuss caching layers, CDN usage, and any replication strategies.
D. **Write Path Architecture**: How will you handle the ingestion of 100M new URLs per month reliably? Discuss any queuing, rate limiting, or consistency considerations.
E. **Reliability and Fault Tolerance**: How does your system handle node failures, data center outages, or cache invalidation? What is your backup and recovery strategy?
F. **Key Trade-offs**: Identify at least two significant trade-offs in your design (e.g., consistency vs. availability, storage cost vs. read performance, simplicity vs. scalability) and explain why you chose the side you did.
Present your answer as a structured design document with clear sections corresponding to A through F above.