URL Shortener diagram template
A read-heavy link shortener with a CDN, cache and key generator in front of a database.
About this design
A URL shortener looks trivial until the traffic numbers arrive: redirects outnumber creations by a hundred to one, so the whole design bends toward fast reads. This template puts a CDN and a Redis cache in front of the link database so a hot short code never touches disk. Creation goes through a separate key generation service that hands out unique, non-guessable codes ahead of time, which avoids both collisions and a write-time lookup. Clicks are not recorded inline; the app emits them to a Kafka topic and an analytics worker aggregates them into a warehouse, so a slow report can never slow a redirect. Use it to discuss base62 versus hashing, expiry, custom aliases and abuse handling. The weak spot is the key service: it needs its own replication story, because every create depends on it.
Diagram as text
This is the source of the diagram, in the ArchBoard diagram DSL. Paste it into Tools, Diagram from text to rebuild or change it.
title "URL shortener"
direction LR
user "Visitors" -> cdn cloudfront "CDN" -> lb nginx "Load balancer" -> service app "Shortener API"
[app x3]
app -> cache redis "Hot links"
app -> db postgres "Links DB"
app -> service keygen "Key generator"
app -[click event]-> topic kafka "Click events" -> worker stats "Analytics" -> warehouse snowflake "Click warehouse"Related guides
More interview classics templates
Pastebin Service
Store and share text snippets with object storage for content and a database for metadata.
Rate Limiter
A distributed rate limiter at the gateway with shared counters and a rules store.
Notification System
Fan out email, SMS and push notifications through a queue with per-channel workers.