system design
System Design: URL Shortener
Design a URL shortener like bit.ly — storage, encoding, caching, analytics.
System Design: URL Shortener
The Problem
Design a URL shortening service like bit.ly. It should generate short URLs, redirect to the original, and track click analytics. Scale: 100M URLs created/month, 10B redirects/month.
API
POST /api/shorten { "url": "https://..." } → { "short": "https://short.ly/abc123" }
GET /abc123 → 301 redirect to original URL
GET /api/analytics/abc123 → { "clicks": 12345, "by_country": {...} }Key Design Decisions
Short Code Generation
Storage
Redirect Flow
Request → Load Balancer → App Server → Redis cache check
↓ miss
Postgres lookup → cache result → 301 redirectAnalytics
Scale Numbers
Your design notes
Work through this problem yourself before reading the walkthrough above. Your notes are stored locally and not submitted anywhere — only sent to the AI when you click Review.