URL Shortener System Design (like Bitly)
Architecture of a URL shortener like Bitly: short code generation, fast redirects through a cache, a key-value database and click analytics. One of the most common system design interview questions.
How it flows
- Browser / App → API Gateway (HTTPS)
- Mobile Client → API Gateway (HTTPS)
- API Gateway → Short Code Service (REST)
- API Gateway → Redirect Service (REST)
- Short Code Service → Key Generation Service (gRPC)
- Key Generation Service → Key Store (Read/Write)
- Short Code Service → URL Database (SQL)
- Redirect Service → Cache (Cache Lookup)
- Cache → URL Database (Cache Miss → SQL)
- Redirect Service → Event Stream (Click Event)
- Event Stream → Analytics Service (Stream)
Components
Browser / App · Mobile Client · API Gateway · Redirect Service · Short Code Service · Key Generation Service · Cache · URL Database · Key Store · Event Stream · Analytics Service