</> 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 7: One Document, Many Phones - Deep Dive: The Storefront & Search

Executive Summary: The storefront is the only part users see and the cheapest to make fast, so it goes first and stays short. Each details page is one ~5 KB document per (package, locale), built from the change feed and cached at the edge for 5 minutes, so ~90% hits cut 174,000 views a second to 17,400 origin builds. Compatibility is a thin per-request check on top of that shared document, never part of the cache key. Search is a small inverted index replicated whole per region, with compatibility filtered inside retrieval and ~1,000 candidates ranked down to 50. Ratings arrive as pre-aggregated histograms.

Section 6 ended with the marker in the candidate's hand. "Where do you want to go deeper?"

You: "Storefront first, because it's what users see and the wins are cheap. About ten minutes. Then delivery, where the load is: 420,000 checks a second and 14.4 Tbps. That's Section 8, and it gets most of the time. Publishing last."

Interviewer: "Why start with the easy one?"

You: "To show why it stays easy. The catalog is 80 GB of listings. That's a caching problem, not a database problem."

The Details Page: One Document per App and Locale

Priya opens Trailhead Maps on her Pixel 7. Her phone sends GET /v1/apps/com.trailhead.maps?locale=hi-IN with the X-Device-Profile header from Section 4. Here is the whole path:

Details-page flow: Priya's Pixel 7 sends GET details with a deviceProfileId to the edge compatibility layer, which also reads ABI, SDK and features from the device profile cache and keys the edge cache (TTL 5 min) by package + locale; 10 percent of requests miss, 17.4k/s at peak, to the Storefront API, which reads a 5 KB document from the Document KV, written by the document builder (one doc per package + locale) from change-feed events and the rating aggregator's 5-bucket histogram, with the change feed fed by committed Catalog DB changes

The document builder listens to the change feed. On a listing edit, release change, takedown or rating update, it rewrites the affected (package, locale) documents in a key-value store. Each holds the localized text, screenshot URLs, the rating histogram, a per-country availability and price block, and a compact requirements block (minSdk, ABIs, required features). 2 million apps × 8 locales = 16 million documents, about 80 GB, which fits in memory on a KV cluster in every region.

The arithmetic follows from Section 3:

Layer Peak rate Why it holds
Edge cache 174,000 views/s Popularity is heavily skewed, so ~90% hit; p50 < 50 ms from the edge
Storefront API + KV 17,400 builds/s 17,400 × 5 KB ≈ 87 MB/s of point reads; p99 < 300 ms on a miss
Document builder Change-feed rate Driven by writes, not views: thousands of changes a minute, not hundreds of thousands a second

Interviewer: "Why not just render the page from the catalog database? It's already strongly consistent."

You: "I rejected that. The catalog DB holds the release state machine publishing commits against, and 174,000 reads a second would put browsing load on the store whose correctness matters most. The storefront tolerates 5 minutes of staleness and runs at 99.95%, not 99.99%, so it reads a derived copy. If the KV or API goes down, the edge serves stale documents (stale-if-error), and update delivery never notices."

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.