
📝 System Design Interview Classics · C4 Architecture · Pro
The classic interview design for a service like bit.ly: short code generation, fast redirects from a cache, and click analytics processed separately.
C4 Architecture diagrams are part of Pro. Anyone can view this one; generating and editing it needs Pro.
Drawing diagram…
URL shortener design: users create short links through a web app and API. A key generation service hands out unused 7-character codes from pre-allocated ranges. Links are stored in Cassandra. The redirect service looks up codes in a Redis cache first, falls back to Cassandra, and returns an HTTP 301 redirect. Each click is sent to Kafka and an analytics service aggregates clicks per link into ClickHouse.
C4Container
title URL Shortener
Person(user, "User", "Creates and shares links")
Person(visitor, "Visitor", "Clicks short links")
System_Boundary(us, "URL Shortener") {
Container(api, "Link API", "Go", "Create and manage links")
Container(kgs, "Key Generation Service", "Go", "Hands out unused codes")
Container(redir, "Redirect Service", "Go", "Looks up code and redirects")
Container(an, "Analytics Service", "Java", "Aggregates clicks")
ContainerDb(cache, "Cache", "Redis", "Hot short codes")
ContainerDb(db, "Link Store", "Cassandra", "Code to long URL")
ContainerQueue(q, "Click Events", "Kafka", "One event per click")
ContainerDb(ch, "Analytics DB", "ClickHouse", "Clicks per link")
}
Rel(user, api, "Creates link", "HTTPS")
Rel(api, kgs, "Gets a code")
Rel(api, db, "Saves link")
Rel(visitor, redir, "Opens short URL", "HTTPS")
Rel(redir, cache, "Reads")
Rel(redir, db, "Reads on cache miss")
Rel(redir, q, "Publishes click")
Rel(an, q, "Consumes")
Rel(an, ch, "Writes counts")How a one-to-one chat message is delivered in a WhatsApp-style system, with sent, delivered and read ticks, and push notifications when the receiver is offline.
How posts reach followers' feeds: fan-out on write for normal users, fan-out on read for celebrities, and a ranked feed built from a cache.
The core of a ride-hailing app: drivers stream their locations, a geo index finds nearby drivers, and a matching service offers the trip to the best one.
How a token bucket rate limiter decides whether to let an API request through, using Redis so all servers share the same counts.
A notification system that sends email, SMS and push messages at scale: one API, a queue per channel, user preferences, and retries.
How search suggestions appear as you type: a prefix index built offline from past searches, served from memory, and refreshed regularly.