SD-3 · Back to the write-up
Design a Pastebin
Keep a small row per paste, put the text in object storage, and let a CDN serve reads, since a paste never changes.
Follow a request
Save a paste
Upload a large paste
Read · CDN hit
Read · CDN miss
Delete a paste
Clean up expired pastes
Clients
Edge
Services
Data
UserBrowser or CLI
CDNEdge copies
Load balancerSpreads traffic
App serversStateless, many
Abuse scannerAsync workers
Expiry sweeperBackground job
Object storagePaste text
Metadata DB8 shards by key
The numbers, at a glance
1 write ≈ 116/s10 reads ≈ 1,160/s
36.5 TBY1
73 TBY2
110 TBY3
146 TBY4
183 TBY5
2% metadata98% paste text
A read, in order
CDN miss shown. On a hit, the edge answers and steps 2 to 9 disappear.
User
CDN
Load balancer
App server
Metadata DB
Object storage
1 GET /p/Ab3dE9xQ
2 forward
3 route
4 GET row (follower)
5 row, ready, not expired
6 GET object
7 text
8 200 + s-maxage
9 200
10 200 page
RequestResponseAsync, does not block
Where the paste text lives
The decision this question is really about.
POST /pastes
INSERT key, 10 KB text
DB: 183 TB
+ One store, one write.− Huge rows slow every query; 183 TB of database disk.
server Aserver B
Ab3d…txt on A only
read via B → 404
+ Fast local reads.− Each paste lives on one machine.
POST /pastes
PUT text → storageINSERT 200 B row
CDN caches the text
+ Cheap, durable, unlimited; small database.− Two writes: text first, then the row.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
User
App server
SQL database
User
Load balancer
App × N
Object storageMetadata DB
User
CDN
Load balancer
App × NExpiry sweeper
Object storageSharded metadata
User
CDN + rate limits
Load balancer
App × NExpiry sweeperAbuse scanner
Object storageSharded metadata
Was this walkthrough useful?Your vote tells us what to improve next.