</> MAANG.io
system design · 301

Advanced

Master system design interviews with scalable architecture patterns, distributed systems, and real-world design challenges.

0/480 solved 0% complete

Section 6: One Truth, Many Copies - High-Level Architecture

Executive Summary: Postgres holds the truth about every listing; the search index, the Redis cache and the CDN's images are derived copies fed by a transactional outbox and Kafka. We justify every box with a number, walk Maya's post and Daniel's search through their paths, and list what is deliberately left off the board, with the trigger that would put it back.

The interviewer hands you the marker: "Draw it." First, say the sentence the diagram must respect.

You: "One source of truth: the listing row in Postgres. The index, the cache and the CDN's images are copies that can lag and be rebuilt. Reads outnumber writes 180 to 1, so I'll draw two paths that share almost nothing: a small, careful write path and a wide, cheap read path."

The Boxes, Each With Its Number

A box earns its place when you can point to the number that needs it (all from Section 3).

Component Job The number that justifies it
CDN Serves every image ~270K image requests/s peak, ~72 Gbps average egress; a 90% hit ratio leaves ~7 Gbps for the origin
API gateway Token auth, rate limits, routing Identity and velocity limits enforced once
Listing service Create, edit, mark sold, renew; detail reads ~300 listing writes/s peak, ~21,000 detail reads/s peak
Media service + image processors Presigned URLs, EXIF strip, 3 variants, perceptual hash 10M photos/day; ~7 Gbps peak ingress that must never cross the app tier
Object storage Private upload quarantine; stripped original and variant bytes 20 TB/day, ~2.2 PB steady state under the 90-day retention rule
Postgres (primary, sync standby, replicas) System of record, outbox One primary handles ~300 writes/s with large headroom
Outbox relay → Kafka Turns committed rows into events Feeds the indexer, moderation, cache invalidation and analytics
Indexer → Elasticsearch Keeps the search copy current ~325 index ops/s; ~120 GB primary: a 32-shard regions index plus one-shard hot-metro indexes
Search service Builds the geo + text query, picks shards ~10,500 QPS peak
Moderation service Sync rules, async ML, review queue < 200 ms inline, p95 < 20 s async, ~40K holds/day
Messaging + WebSocket gateway + push Masked buyer–seller chat ~1,400 messages/s peak, 2M concurrent connections on 40 gateway nodes
Redis Listing-detail cache 16 GB hot set; 90% hits leave ~2,100 QPS for the replicas

Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.