Viewed
System Design
OpenAI
GPT-5.2
VS
Google
Gemini 2.5 Pro
Design a URL Shortening Service
Design a URL shortening service similar to bit.ly or TinyURL. Your design should address the following aspects:
1. **Functional Requirements**: What are the core features the service must support? Consider URL creation, redirection, expiration, and analytics.
2. **High-Level Architecture**: Describe the main components of the system (e.g., API layer, application servers, databases, caches, load balancers). Explain how they interact.
3. **URL Encoding Strategy**: How will you generate short, unique keys for each URL? Discuss your approach (e.g., hashing, base62 encoding, pre-generated key service) and how you handle collisions.
4. **Database Design**: What database(s) would you use and why? Provide the schema for the core table(s). Discuss the trade-offs between SQL and NoSQL for this use case.
5. **Scalability and Performance**: How would you handle high read traffic (e.g., millions of redirects per day)? Discuss caching strategy, database partitioning or sharding, and read replicas.
6. **Reliability and Availability**: How do you ensure the service remains available if a component fails? Discuss redundancy, replication, and failover strategies.
7. **Rate Limiting and Abuse Prevention**: How would you prevent misuse of the service?
Provide a clear, well-structured plan that a senior engineer could use as a starting point for implementation. Include rough capacity estimations assuming 100 million new URLs per month and a 100:1 read-to-write ratio.