Section 5: Two Kinds of Truth - Data Modeling
Executive Summary: Section 4's rich responses sit on a deliberately small model split into two kinds of data. The source of truth is relational and strongly consistent. Apps, artifacts and releases are keyed by package name, files by their SHA-256, and purchases and entitlements are keyed by user. The derived stores (the 1.8 GB update index, storefront documents, search documents) are rebuilt from its change feed and may lag by seconds or minutes. We trace Trailhead's release and Priya's ₹399 purchase through the rows, and defend the two keys that matter most: files keyed by their SHA-256, and entitlements keyed by userId.
The interviewer points at Section 4's update-check response. "Every one of those fields came from somewhere. Show me the tables, and tell me which ones you'd let be stale."
That second question is the real one: this model is mostly a decision about which data must be right and which must be fast. The two sets barely overlap.
Access Patterns Before Tables
| Pattern | Keyed by | Load | Consistency |
|---|---|---|---|
| Update check: latest eligible release per installed app | package |
420,000 checks/s, 16.8M lookups/s | Eventual, ≤ 60 s |
| Details page for one app | (package, locale) |
174,000/s peak, ~17,400/s at origin | Eventual, ≤ 5 min |
| Search | terms, filtered by country/ABI/minSdk | 35,000/s peak | Eventual, minutes |
| Install manifest: files for this device | variant_manifests by (artifactId, variantKey, fromVersionCode) |
10,500 installs/s peak | Immutable once written |
| "What do I own?" (install, restore) | userId |
Every paid install, every new phone | Read-your-writes for the buyer |
| Record a purchase | userId + idempotency key |
1,740/s peak | Strong, RPO 0 |
| Release transitions (rollout, halt) | package |
~1.7 submissions/s peak | Strong, transactional |
Only the bottom three rows need strong consistency, and they carry a few thousand operations a second. The top three carry the hundreds of thousands. That asymmetry shapes the whole model.
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