System 12.5 — Pastebin
In one line
URL shortener + file storage hybrid: text blobs with read-once/expiry semantics.
Think of it like this
A text version of a URL shortener — you paste some text, get a short link back, and anyone with that link can read the text, sometimes only once before it self-destructs.
Key ideas
- 01
Write path: POST text → store blob (DB/object store) → return short id; reads GET /{id} → render.
- 02
Unlike shortener: content is large and VALUES-ranked not just read — cache and DB lightly.
- 03
Unlisted vs secret: secret pastes use unguessable random ids (not counters) — read-once/expiry via TTL rows.
- 04
Scale: 10k/day writes, reads 10:1; blob sizes 1KB–10MB → object store + metadata row.
- 05
Syntax highlighting: client-side render; server only stores raw text.
- 06
Consistency: none beyond read-your-writes; TTL sweeper deletes expired blobs + rows.
- 07
Interview lesson: it's 90% shortener + 10% blob — say that and go fast.
Code & diagrams
90% shortener, 10% blob — the diagram is almost identical to url-shortener with a bigger payload.
Explain without notes
Why do secret pastes need random ids while public shortlinks can use counters?
Practice
Migrate-paste into the shortener design: what changes in storage and TTL sweeper?
Trade-offs
- ↔
DB storage simple vs object-store cheaper per GB — pick by paste size histogram.
Completion checklist
I can produce pastebin as 'shortener + blob + TTL' in one breath.