System Design
Beginner
Design a URL Shortener
Build a small but complete design covering redirects, storage, analytics, and abuse prevention.
30 min
3 sections
url-shortener
redirects
analytics
1
2
3
01. Core design
Section 1 of 3
The write path creates a short code and stores the mapping. The read path redirects quickly. Redirects are high-volume reads, so the hot path should use cache and avoid synchronous analytics writes.
text
POST /v1/links
{
"longUrl": "https://example.com/campaign",
"customAlias": "summer-sale",
"expiresAt": "2026-09-01T00:00:00Z"
}
GET /summer-sale
-> cache lookup
-> database fallback
-> 302 redirect
-> async click eventBack to Course