Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 02

Design a Pastebin-style text sharing service

Foundations · 25 min · Storage & data modeling

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

Done on paper? Compare with the worked approaches