Post 01 · DDIA Ch. 1–2
Foundations
Twitter serves ~300k timeline reads/s and ~12k tweets/s — same product, opposite extremes. Before you can build for that, you need three tools: a way to see the load, a way to measure it honestly, and a data model that fits the shape.
Six visuals. Two chapters. One story: what a data-intensive app actually has to survive.
Twitter's timeline is a read-heavy workload sitting on top of a write-heavy social graph. Two ways to build it: fan-out on read (join followers' tweets at query time — cheap writes, expensive reads) or fan-out on write (materialise each user's timeline on every tweet — cheap reads, expensive writes for anyone with millions of followers). Neither is right; Twitter runs a hybrid.
Fan-out
Four scenes · use ‹ › to step, or watch it play through.
Averages hide the users who suffer. If p50 is 10ms and p99 is 2s, one in a hundred requests is a full-page freeze — and those requests are usually the same power users, hitting the biggest queries, over and over. Percentiles are how you see the tail; the tail is where your reputation lives.
Understanding Percentiles
The average sits above p50, dragged up by the tail.
One page makes N backend calls. Its p99 is the slowest of N. A "1 in 100" event fires per call, not per page.
Takeaway
Average latency lies. p99 is what your users feel.
Everything in the book hangs off three words: reliability (works correctly under adversity), scalability (keeps working as load grows), maintainability (the next engineer can extend it without dread). Every trade-off in the coming chapters is a bet on which of the three matters most right now.
Three pillars of a data-intensive app.
Reliability
the system keeps working correctly, even when things go wrong.
Scalability
the system copes when load grows.
Maintainability
people can keep working on the system.
everything in ddia hangs off these three concerns. the rest of the book is one long argument about how they trade off.
Reliability, scalability, maintainability — the framework says what you're optimising for. The next question is what you're storing. The shape of your data picks the database.
A résumé looks like a nested document: one person, arrays of jobs, arrays of schools. Store it as JSON and reads are one lookup. Normalise it into SQL tables and reads become joins — but IDs stay stable and referential integrity is free. Turn it into a graph and connections between people become first-class. Same data, three physical shapes, three different sets of queries that are cheap.
Same résumé, three shapes
One profile · one JSON blob · four joined tables · a small graph.
The moment your data has real many-to-many relationships — people who share employers, tags that belong to many posts, friends of friends — the document model starts hurting. Joins that the relational model does in one query become application-level nested fetches, and consistency across the copies of a duplicated field becomes your problem. Connectedness pushes you toward relational or graph.
The many-to-many problem
Same edit, two data models.
Three writes vs one. Documents still win on read locality: one lookup returns the whole record.
No universal winner. The decision is: how tree-like is my data, how connected is it, and how often does the shape change? Documents win when reads are one-object, writes are self-contained, and the schema wanders. Relational wins when joins are the norm and constraints matter. Graph wins when the interesting questions are about paths between things.
Pick by shape.
Document
one-to-many, self-contained.
Relational
many-to-many with shared entities.
Graph
highly connected, variable depth.
Same résumé, three physical shapes. Pick by how connected your data is.
Takeaway
The shape of your relationships picks the database. Not hype.