Case Study: Design a URL Shortener
URL shorteners receive a long URL, generate a short code, and redirect users. It sounds trivial but the production version touches almost every system design concept: write throughput, read throughput 100× higher, caching, database choice, collision handling, and analytics at scale. Scale estimate: 100M URLs shortened per day = ~1,200 writes/sec. Redirects at 10:1 read ratio = 12,000 reads/sec, each must complete under 10ms. Design: Postgres handles writes. A Redis cache serves the top 20% of codes that account for 80% of traffic (Pareto distribution). The short code is base62 of a database counter — no hash collisions. Analytics events go to Kafka and are processed asynchronously, never in the redirect critical path.