Design a URL Shortener
Design a URL shortener: it turns long links into short codes and serves the redirect at very high volume.
Functional:
- Create a short code for a submitted URL and return the full short link.
- Redirect a visitor from the short code to the destination.
- Support user-chosen custom aliases in the same namespace as generated codes.
- Support an optional expiry date, after which the link stops resolving.
- Report per-link click analytics: total clicks, clicks over time, coarse geography, and referrer.
Non-functional:
- Redirects are the product. They stay fast and available even while the create path or the analytics pipeline is degraded.
- A code is never reused and never resolves to the wrong destination.
- Analytics may lag by a minute. Redirects may not lag at all.
- 5M new links per day, about 58 writes/sec average and 200/sec at peak.
- 2B redirects per day, about 23k reads/sec average and 70k/sec at peak, so the read to write ratio is roughly 400:1.
- Destination URLs average 120 bytes and are capped at 2KB.
- Mapping rows grow about 0.9TB per year. Click events, stored raw, grow about 400GB per day.
- Target p99 of 50ms for a redirect measured at the edge, and 200ms for link creation.
- One link can take 30% of all traffic for several hours when it lands on a large social feed.
Account signup and billing, the dashboard front end, QR image rendering, and malware scanning beyond a blocklist lookup.
Accepted 3/60
Acceptance 5%
Loading editor...
Submit your design to grade it.
- The components and connections this prompt needs
- Structure: an entry point, data stores, async work, and failure handling
- The concepts you explain on the board or in Notes, in your own words
To pass, score 65 or more with every required component but one, and name at least half the concepts, or all of them if a component is missing.