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 a Flash Sale System
System Design / System Design Problems 23 min readBuilding a system to handle millions of concurrent users competing for limited inventory during time-bounded sales events. Flash sales present a unique challenge: extreme traffic spikes (10-100x normal) concentrated in seconds, with zero tolerance for inventory errors. This design covers virtual waiting rooms, atomic inventory management, and asynchronous order processing.
-
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.