URL Shortener Design: IDs, Storage, and Scale
A comprehensive guide to designing a scalable URL shortening service like bit.ly or TinyURL.
Requirements
Functional Requirements
- Generate short URLs from long URLs
- Redirect short URLs to original URLs
- Optional: Custom short URLs
- Optional: Analytics and tracking
Non-Functional Requirements
- High availability
- Low latency redirects
- Scalable to billions of URLs
High-Level Design
The system consists of:
- API Gateway: Handles incoming requests
- URL Service: Generates and manages short URLs
- Database: Stores URL mappings
- Cache: For frequently accessed URLs
Key Design Decisions
URL Encoding
- Base62 encoding (a-z, A-Z, 0-9)
- 7 characters = 62^7 = ~3.5 trillion unique URLs
Database Choice
- NoSQL (e.g., DynamoDB, Cassandra) for high write throughput
- Key-value store optimized for lookups
Coming Soon
More detailed implementation notes coming soon…
Read more
-
Previous
Design Amazon Shopping Cart
System Design / System Design Problems 22 min readA system design for an e-commerce shopping cart handling millions of concurrent users, real-time inventory, dynamic pricing, and distributed checkout. This design focuses on high availability during flash sales, consistent inventory management, and seamless guest-to-user cart transitions.
-
Next
Design a Cookie Consent Service
System Design / System Design Problems 25 min readBuilding a multi-tenant consent management platform that handles regulatory compliance (GDPR, CCPA, LGPD) at scale. Cookie consent services face unique challenges: read-heavy traffic patterns (every page load queries consent status), strict latency requirements (consent checks block page rendering), regulatory complexity across jurisdictions, and the need to merge anonymous visitor consent with authenticated user profiles. This design covers edge-cached consent delivery, anonymous-to-authenticated identity migration, and a multi-tenant architecture serving thousands of websites.