ExampleLinks
URL Shortener
Billions of redirects, a tiny write path.
A bit.ly-style service: a write-light, read-heavy system where short codes are generated once and resolved millions of times. The whole design hinges on absorbing redirect reads before they reach the database.
2.0M
Daily active users
30
Requests / user / day
95%
Read ratio
90%
Cache hit ratio
The components
Web & Mobilelow risk
End-user web or mobile app that originates requests.
Load Balancermedium risk
Distributes traffic across healthy backends.
API Gatewaymedium risk
Single entry point: routing, auth, rate limiting.
Shortener Servicemedium risk
Monolithic or primary application server.
Redirect Cachelow risk
In-memory key/value store (Redis / Memcached).
Link Storehigh risk
Primary system of record (relational or document).
Click Analyticslow risk
Event pipeline + warehouse for product analytics.
How requests flow
- Web & MobileLoad Balancer
- Load BalancerAPI Gateway
- API GatewayShortener Service
- Shortener ServiceRedirect Cache— lookup
- Shortener ServiceLink Store— miss / write
- Shortener ServiceClick Analytics— click event
Traffic assumptions
- Reads (redirect lookups) outnumber writes (link creation) ~20:1.
- Hot links concentrate traffic — a small set of codes drive most reads.
- Redirect latency must stay low: it sits on the user's critical path.
- Short codes are immutable once created, which makes them trivially cacheable.
Scaling strategy
- Put a cache in front of the database; a 90%+ hit rate keeps DB load flat as traffic grows.
- Generate codes with a counter/base62 or hashing scheme to avoid read-before-write contention.
- Add read replicas only if cache misses still pressure the primary.
- Push static assets and 301/302 responses to the CDN edge where possible.
Known bottlenecks
- The primary database on a cache-miss storm (cold cache after deploy).
- Hot-key skew overwhelming a single cache shard.
- Analytics writes contending with redirect reads if they share the path.
Tradeoffs
- 301 (permanent) caching boosts speed but makes link edits/expiry hard to honor.
- Counter-based codes are dense but leak volume; hashed codes are opaque but can collide.
- Synchronous click analytics add latency; async via a queue trades freshness for speed.
Make it yours.
Load this design into the editor, push traffic through the simulator, and watch the database bottleneck appear as you scale.
Open URL Shortener in editor