SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 02
Design a Pastebin-style text sharing service
A developer pastes a stack trace or a config file, picks an expiry, and gets a link to drop into a chat or a bug report. Whoever opens the link sees the exact text, and after the expiry nobody should see it again.
Requirements
- Create a paste from up to 1 MB of text and return a link to it.
- Show the exact original text to anyone who opens the link.
- Support expiry options of 10 minutes, 1 day, 1 week, or never.
- Let the creator delete a paste using a secret delete token returned at creation.
Constraints and assumptions
- 2 million new pastes a day; average size 10 KB, maximum 1 MB.
- About 10 reads per paste on average, but a few pastes linked from busy forums get tens of thousands of views.
- Unlisted pastes are private by obscurity: the link must not be guessable or enumerable.
- An expired or deleted paste must stop being served within 1 minute; its storage should be reclaimed within a day.
- p99 read latency under 100 ms for pastes up to 1 MB.
Out of scope for the first sketch
User accounts and paste lists · Syntax highlighting · Editing a paste after creation
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design a Pastebin-style text sharing service
Finish your first sketch before answering these. Cross out freely.
- A 200-byte paste and a 1 MB paste arrive. Where does each one live, and why?
- Millions of pastes expire every day. How do you stop serving them on time and reclaim the space without scanning everything?
- A paste linked from a popular forum gets 50,000 views in a minute. Which part of your design serves those reads?
- Product adds "burn after reading": a paste can be viewed exactly once, even if two people open it at the same moment. What changes?
Compare afterwards: worked approaches and reading at sketchbook /questions/pastebin/review