How would you design a URL shortener like bit.ly?
🏗️ System Design• 9/21/2025
System design for URL shortening service covering encoding algorithms, database design, caching, and scalability considerations.
URL Shortener System Design
Requirements
Functional:
- Shorten long URLs to short URLs
- Redirect short URLs to original URLs
- Custom aliases (optional)
- URL expiration
- Analytics
Non-Functional:
- 100:1 read/write ratio
- 100M URLs shortened per day
- Low latency < 100ms
- 99.9% availability
High-Level Architecture
[Client] → [Load Balancer] → [API Gateway] → [App Servers]
↓
[Cache Layer] ← → [Database] ← → [Analytics DB]
URL Encoding Approaches
- Base62 Encoding - Convert unique ID to base62
- Hash-based - MD5/SHA1 hash of URL
- Counter-based - Auto-incrementing counter
Database Design
- Primary table: urls (id, short_url, long_url, created_at, expires_at)
- Indexes on short_url for fast lookups
- Sharding by short_url for scalability
By: System Admin