Practice: Design a QR Code Service
QR code service inspired by QR Code Generator and Bitly codes: dynamic codes point to a short link whose destination can be edited, scans resolve from the edge, and scan analytics are counted in the background.
Build this system yourself on the canvas below. Add components, connect them, and run traffic simulations to see where your design holds up and where it breaks.
Functional requirements
- Create a dynamic QR code that points to a short link, and return the image to the owner
- Resolve a scan to the current destination as fast as possible, from the edge when it can
- Let the owner change a code's destination without changing the printed QR code
- Count every scan per code (time, rough location, device) without slowing down the redirect
- Show the owner scan counts over time
- Never reuse or expire a code unless the owner deletes it, even if it was printed years ago
- Limit how many codes and edits one account can create per minute
Non-functional requirements
- Scan redirect < 50ms p99 for cached codes and < 150ms on a cache miss
- A changed destination is live everywhere within 30 seconds (cache entries expire or are purged)
- Handle 10K scans per second at peak and 100 code creates or edits per second
- Scan counts may lag by up to a minute, but no scan is lost (counted through a queue)
- 99.99% availability for scans: a printed code must keep working even if creation is down
- Scale to 1B codes, never reused
- 99.99% durability for code and destination records