SD-38 · Back to the write-up
Design a Social Marketplace
Listings live in a database; a change stream copies live ones into a geo and text index, hot searches come from a cache, and photos come from a CDN.
Follow a request
Post a listing
Search · cache miss
Search · cache hit
Mark sold
Photo from the edge
Clients
Edge
Services
Pipeline
Data
Buyer or sellerApp or web
Image CDNPhoto sizes
Result cacheHot searches
Photo storageOriginals
Listing serviceWrite + view
Search serviceQuery + rank
Review workersTrust and safety
Change streamRow changes
IndexerStream → index
Listings DB16 shards
Search index8 region shards
The numbers, at a glance
1 write ≈ 500/s40 searches ≈ 20,000/s
50% reach the index20,000 searches/s
≈ 0.2 GB/sAPI
≈ 14 GB/sPhotos
A search, in order
Cache miss shown. On a hit, steps 3 and 4 disappear.
Buyer
Search service
Result cache
Search index
Image CDN
1 GET /search?q=bike
2 GET cell + query
3 miss
4 geo + text, top 500
5 500 ids + scores
6 SET page, 60 s
7 24 results
8 GET thumbnails
9 photos from edge
RequestResponseAsync, does not block
How the index follows the database
The decision that keeps sold items out of search.
PATCH sold
UPDATE rowindex write fails
sold bike in search
+ Simple, no extra system.− A failed second write leaves the index wrong.
PATCH sold
UPDATE row
index fixed tomorrow
+ Always consistent after a run.− Up to a day behind.
PATCH sold
UPDATE row
change log → indexer
removed in seconds
+ Every committed change, in order, within seconds.− A stream and an indexer to run.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
Buyer
App server
DatabasePhoto storage
Buyer
Listing serviceSearch service
Change streamIndexer
Listings DBSearch index
BuyerImage CDN
Listing serviceSearch serviceResult cache
Change streamIndexer
Listings DB × 16Index × 8 regions
BuyerImage CDN
Listing serviceSearch serviceResult cache
Change streamIndexerReview workers
Listings DBSearch index
Was this walkthrough useful?Your vote tells us what to improve next.