Design a service that turns long URLs into short links, redirects on access, and reports click counts.
How to approach it
Sketch the request path from the client inward: client → edge/CDN → load balancer → stateless services → cache → database, with queues and workers off to the side for async work. Keep services stateless so they scale horizontally. Draw the happy path first; resilience and scale come after.
Components
| Component | Role |
|---|---|
| Client | browser / app |
| CDN / Edge | cache hot redirects |
| Load Balancer | L7 routing |
| Link Service | stateless create + redirect |
| Redis | code→url cache-aside |
| Key-Value DB | durable mapping, sharded by code |
| Queue | click events |
| Analytics Worker | roll up counts |
Request path
Client → CDN / Edge → Load Balancer → Link Service → Redis → Key-Value DB