Trade-Offs in Data Systems

One database cannot serve the checkout and the monthly report well at the same time. Run the report on the shop database and checkouts slow from 4.3 ms to 30 ms. Run it on a copy and the report may read data 25.5 hours old.

Pick where the revenue report runs, drag its size and press Run. Then we build each trade piece by piece: query shapes, columns, copies, derived data, cloud costs, distribution and the law.

You need a little Python and what a database table is. We build the rest from zero.

Run the revenue report somewhere

50 million

Illustrative model. Order rows are 200 bytes, and the report reads 12 bytes of columns a row. The disk reads 500 MB/s, and one checkout read takes 3 ms. The disk is 30% busy before the scan and 90% during it. Chapters 1 to 3 derive each number.

Chapter 0

One App, Many Data Systems

Follow one click through a shop and count the systems it touches

You run an online shop. A customer buys a lamp. That click writes one row to the orders database. It must also change the cached product page, the search index that says how many lamps are left, and the report finance reads on Monday.

So the shop is not one database. It is several data systems, each good at one job, wired together by your code. Your code decides how they stay in step. That makes you the designer of a new data system, whether you meant to be or not.

Trace one action through the shop

Purple boxes hold the record. Teal boxes are copies computed from it. Pick an action and watch the blue messages travel.

Illustrative shop. Real shops add more boxes (payments, email, a recommendation model), but the pattern is the same: one record, many copies.

Buying a lamp touches 5 of the 6 boxes: 1 write to the record, 1 entry in its log, and 3 copies to update. Viewing a product touches 1. The read paths are short because the write path did the work.

This lesson follows Chapter 1 of Designing Data-Intensive Applications, 2nd edition, by Martin Kleppmann and Chris Riccomini (O'Reilly, 2026). The chapter maps the big choices made before any code: operational versus analytical systems, cloud versus self-hosting, and one node versus many. It ends with the law. We explain the ideas in our own words, with our own shop and numbers.

No choice is free. Each one moves a cost: to latency, to freshness, to money, to the people who run the system. The hero showed one trade. A report on the shop database slows checkouts. A report on a copy reads old data. Reliability, scalability and maintainability get their own lesson, Nonfunctional Requirements.

Failure. Symptom: search shows a lamp in stock that sold out an hour ago. Measure: compare the stock count in the search index with the orders database. Cause: the code updated the record and missed one copy. Fix: list every copy each write must reach; Chapter 4 shows a safer pattern.

  1. Two kinds of queries: a checkout reads one row, a report reads them all.
  2. Columns: store data so a scan reads only what it needs.
  3. The warehouse: copy the data out, and pay in freshness.
  4. Record and derived data: one source of truth, many copies.
  5. Cloud or self-hosted: the break-even utilization.
  6. Storage apart from compute: pay for disks and CPUs separately.
  7. One node or many: partial failure is the price of distribution.
  8. Data, law and people: erasing a person from every copy.
  9. The showcase: design the shop's data system.
  10. The field guide: numbers, checklist, code and links.
A product page reads the price from a cache. The price changed in the orders database 10 minutes ago, and the page still shows the old price. What went wrong?

Chapter 1

Two Kinds of Queries

Count the rows each query touches, and see why one database struggles to serve both

A checkout asks: show order 4711, then mark it paid. It reads one row by its key and writes one row. Thousands of customers ask this each second, and each wants an answer in milliseconds. This is online transaction processing (OLTP): many small reads and writes by key, sent by the app.

Finance asks: what was revenue per month over two years? That query reads every order but returns 24 numbers. A few analysts ask it a few times a day. This is online analytic processing (OLAP): a few large queries that scan many rows and aggregate them.

Read one row, or read them all

Each cell stands for a slice of the orders table. Run each query and watch which cells it reads. Then grow the table.

50 million

Illustrative: 200-byte rows and 500 MB/s of disk reads. A real key lookup reads one 8 KB page through an index, and its time is the disk's wait, not its bandwidth.

The difference is how much data each query touches. Call the number of rows a query reads n and the bytes in one row w. Call the disk's read speed B, in bytes per second. The time a query spends reading is T.

Say it aloud

T equals n times w, divided by B.

T
T the time the query spends reading, in seconds.
n
n the number of rows the query must read: 1 for a key lookup, every row for a scan.
w
w the bytes in one row: 200 bytes for an order here.
B
B the read bandwidth: how many bytes the disk delivers each second.
In plain words

Count the rows n the query reads. Multiply by the bytes w in each row. Divide by the bytes B the disk reads per second. The result is the reading time T.

With numbers

With made-up numbers: w = 200 bytes and B = 500 MB/s. The report reads n = 50 million rows, so 10 GB, and T = 10 GB / 500 MB/s = 20 s. The checkout reads n = 1 row, 200 bytes. The two queries differ in bytes by a factor of 50 million.

The checkout uses an index, a lookup structure that jumps to a row by its key. So its n stays at one row as the table grows. The report has no shortcut: its n grows with the business. Double the table, and the report takes twice as long.

PropertyOLTP (the shop)OLAP (the report)
Who asksthe app, for customersanalysts and dashboards
Readsa few rows, by keymillions of rows, a few columns
Writessingle rows, as they happenbulk loads, or none
Answer wanted inmillisecondsseconds to minutes

Failure. Symptom: a dashboard query took 2 s at launch and takes 40 s a year later. Measure: the query plan shows a full table scan, and rows read per run. Cause: n grows with the table, so T grows too. Fix: move the scan to a store built for it (Chapters 2 and 3), or keep a running total.

The orders table grows from 10 million to 40 million rows. What happens to a key lookup through an index, and to a full scan?

Chapter 2

Store by Column for Scans

Lay each column out on its own, so a report reads only the bytes it names

Look again at the report. It reads 50 million orders but needs only two fields: the date (4 bytes) and the amount (8 bytes). The other 188 bytes of each row hold the customer, the address and a comment. A row store keeps all 200 bytes of a row side by side on disk. To read 12 bytes, it reads all 200.

A column store keeps each column in its own place on disk. All the dates sit together, then all the amounts. A query reads only the columns it names. Apache Parquet, a common file format for analytics, works this way; its docs call it "column-oriented".

Choose the columns a query reads

Each column's width shows its bytes. Switch the columns your query needs, then compare the row layout with the column layout.

Columns the query reads

Illustrative 200-byte order row over 50 million rows at 500 MB/s. Real column stores also compress each column, which saves more; we leave compression out.

Add up the bytes per row of the columns the query uses, and call the sum Σ wused. Call the rows n again. The bytes a column store reads are Dcol.

Say it aloud

D-col equals n times the sum of w-used.

Dcol
D-col the bytes a column store reads for this query.
n
n the number of rows scanned: 50 million orders.
Σ wused
the sum of w-used add the width in bytes of each column the query names. A row store reads the full row width, w-row, instead.
In plain words

Add the widths of only the columns the query needs. Multiply by the rows n. That is D-col. A row store reads n times the whole row width, w-row.

With numbers

With made-up numbers: n = 50 million and the sum of w-used = 4 + 8 = 12 bytes. D-col = 600 MB. A row store reads 50 million × 200 = 10 GB. At 500 MB/s that is 1.2 s against 20 s: 16.7 times less.

The price is paid on writes. One new order now goes to eight column files instead of one place. So column stores take writes in large sorted batches, and they suit bulk loads, not single checkouts. One layout cannot be best at both jobs. Storage and Retrieval and Data Storage show how column stores write and compress their files.

Failure. Symptom: a column-store table loads orders one at a time, and loading falls behind. Measure: rows per write call, and the count of small files. Cause: each single-row insert touches every column. Fix: batch thousands of rows per load, or keep single-row writes in the shop database.

Rows are 200 bytes wide. A query reads three columns of 8 bytes each. How many times fewer bytes does a column store read than a row store?

Chapter 3

Copy the Data Out for Analytics

Move the report off the shop's disk, and pay for it in freshness

Why not run the report on the shop database anyway? Because both queries share one disk. While the report scans, the disk is busy, and each checkout waits in line behind it.

Model the disk as one queue. Call the time one checkout's disk read takes s. Call the fraction of time the disk is busy ρ (rho). The average time a checkout spends at the disk, waiting and in service, is R.

Say it aloud

R equals s divided by one minus rho.

R
R the average time a checkout spends at the disk, waiting and served, in milliseconds.
s
s the service time: one checkout's disk read with no queue, 3 ms here.
1 −
one minus turns "busy" into "free": the share of time the disk is idle.
ρ
rho the utilization: the fraction of time the disk is busy, from 0 to just under 1.
In plain words

Take the idle share of the disk, 1 minus rho. Divide the service time s by it. As rho nears 1, the idle share nears zero, and R grows without limit.

With numbers

With made-up numbers: s = 3 ms. Before the scan, rho = 0.3, so R = 3 / 0.7 = 4.3 ms. During the scan, rho = 0.9, so R = 3 / 0.1 = 30 ms. The same checkout is 7 times slower for the 20 s the report runs.

So companies copy the data into a data warehouse: a separate database used only for analytics, often a column store. An ETL pipeline (extract, transform, load) reads each operational system's changes, cleans them and loads them. The warehouse can also join data from many systems: orders, payments, support tickets.

Trade checkout speed for freshness

The left curve is R against rho; the dots are checkouts before and during a report. The right line is the warehouse's data age. Move the report, then change the load schedule.

60%

Illustrative: one disk modelled as one queue with random arrivals (the M/M/1 model), s = 3 ms and 30% base load. We made up the load times.

The copy is only as fresh as its last load. Call the time between loads I and the time one load runs L. The oldest data a report can see is Amax.

Say it aloud

A-max equals I plus L.

Amax
A-max the worst-case age of the warehouse data, just before the next load finishes.
I
I the interval from the start of one load to the start of the next.
L
L how long one load runs. Its data is as old as the moment it started.
In plain words

A load takes a snapshot when it starts and shows it L later. The next snapshot shows up I after that. Add the interval I and the run time L to get the worst age.

With numbers

With made-up numbers: a nightly load, I = 24 h, that runs L = 1.5 h. A-max = 25.5 h. An hourly load of 15 minutes gives 1 + 0.25 = 1.25 h, but 24 loads a day to run and watch.

A data lake skips the cleaning at load time. It keeps raw files, often Parquet, and each team transforms them later.

Failure. Symptom: checkout latency spikes every night at 02:00. Measure: disk busy percent and the queries running then. Cause: the ETL extract scans the shop's primary database. Fix: extract from a replica (Replication) or from a change log (Stream Processing).

A warehouse load starts every 6 hours and runs for 30 minutes. What is the oldest data a report can see?

Chapter 4

Systems of Record and Derived Data

Keep one source of truth, and feed every copy from it in order

Every copy needs a source. The system of record holds the authoritative version of a fact. When copies disagree, it wins. In our shop, the orders database is the system of record for orders.

Everything computed from it is derived data: the cache, the search index, the warehouse. Lose a derived copy and you rebuild it from the record. Lose the record and the fact is gone.

How do the copies stay in step? The tempting answer is dual writes: the app writes the database, then the cache, then the search index. Each write can fail on its own. Call the chance that one write fails p, and the number of systems the app writes k. The chance the copies end up disagreeing is P.

Say it aloud

P equals one minus, one minus p, to the k.

P
P the chance that at least one of the k writes fails, so the copies disagree.
1 −
one minus turns "all succeed" into "some failed".
1 − p
one minus p the chance one write succeeds. p is the chance it fails, 1 in 10,000 here.
k
to the k multiply by itself once per system written: k = 3 for database, cache and index.
In plain words

One write succeeds with chance 1 minus p. Multiply that k times for all k writes to succeed. One minus the result is the chance some write failed. (All k failing at once has chance p to the k, too small to count.)

With numbers

With made-up numbers: p = 0.0001 and k = 3. P = 1 − 0.99993 = 0.0003, or 0.03%. At 500 orders a second that is 0.15 a second: about 13,000 orders a day where the copies disagree, and nobody is told.

Write 10,000 orders two ways

Each strip is one system; each cell is 10 orders. Red cells hold a copy that disagrees with the record. Pick a pattern, set the failure rate and press Write.

1 in 1,000

Illustrative: each write fails at random with the chance you set. With the change log, the log retries each failed update, so copies lag the record (yellow) but end up equal.

Dual writes have a second fault. Two updates to one item can reach the cache and the index in different orders, so each ends with a different value. The safer pattern writes only the record and lets its change log feed every copy in order. The log retries a failed update, so copies lag but never drift. Stream Processing and Messaging build this.

Failure. Symptom: search lists a product the database deleted last week. Measure: a nightly job that compares counts or checksums of the record and each copy. Cause: a dual write failed or arrived out of order. Fix: rebuild the copy from the record, and move to log-based updates.

The cache says a lamp costs $40. The orders database, the system of record, says $45. What do you do?

Chapter 5

Cloud or Self-Hosted

Find the utilization where renting by the hour stops being cheaper than owning

Where do the machines live? You can self-host: buy servers and run the database yourself. Or you can use a cloud service: rent machines by the hour, or rent a managed database that the provider runs.

The cost shapes differ. Owned machines cost the same busy or idle, so you pay for the peak all month. Cloud machines cost more per hour, but you turn them off when load drops, and you need fewer people to run them.

Name the parts. P is the number of machines the peak needs. cown is one owned machine's monthly cost: hardware spread over its life, power and space. ccloud is one cloud machine run for a whole month. u is the average fraction of the peak in use. F is the extra monthly cost of the people who run your own machines.

self-hosted: Cself = P · cown + F pay for the peak, always cloud: Ccloud = u · P · ccloud pay for what you use

The two costs are equal at one value of u, the break-even utilization u*.

Say it aloud

u-star equals P times c-own plus F, all divided by P times c-cloud.

u*
u-star the break-even utilization. Below it the cloud costs less; above it, owning costs less.
P
P the machines the peak load needs.
cown
c-own one owned machine's cost per month.
F
F the extra staff cost per month of running your own machines.
P
P the same peak machine count, now priced in the cloud.
ccloud
c-cloud one cloud machine's cost for a full month.
In plain words

Add up a month of owned machines, P times c-own, and the extra staff F. Divide by a full month of the same peak in the cloud, P times c-cloud. If your average use u is below u-star, rent.

With numbers

Illustrative prices: P = 40, c-own = $250, c-cloud = $700, F = $15,000. Owning costs $25,000 a month, so u* = 25,000 / 28,000 = 0.89. A shop busy only around sales, u = 0.3, pays $8,400 in the cloud. A steady ledger at u = 0.95 pays $26,600, more than owning.

Price the same fleet two ways

Warm is machines doing work, pink is machines paid for but idle, yellow is the extra staff time. The ruler below marks u and u*. Drag the utilization, then change the fleet.

30%

Illustrative prices, not any provider's list: $250 per owned machine-month, $700 per cloud machine-month on demand, $15,000 a month of extra staff. Reserved cloud pricing and real salaries move u*; the shape stays.

Size moves the line. At P = 400 the staff cost is spread over more machines, and u* falls to 0.41. That is why large, steady fleets sometimes move back to their own hardware. Money is not the whole trade. The cloud gives fast scaling and managed backups. It takes away control, ties you to one provider's interfaces, and many providers charge for data that leaves their network.

Failure. Symptom: the cloud bill doubles, but traffic did not. Measure: the average utilization of each machine, and the bill by line item. Cause: machines sized for the peak and left running, so you pay cloud prices without the elasticity. Fix: autoscale or schedule shutdowns, and commit only to the steady base.

P = 10, c-own = $250, c-cloud = $700 and F = $15,000. At what utilization does owning become cheaper?

Chapter 6

Storage Apart From Compute

Buy disks and processors separately, so each grows only when you need it

In a classic database, each machine holds part of the data on its own disk and runs the queries for that part. Storage and compute grow together. Need more disk? Add a whole machine, with processors you may not need.

Cloud-native systems split the two. The data lives in object storage: a service that keeps files by name, bills per terabyte per month and keeps its own copies for safety. Query machines are separate. They read what they need, cache it on local disk, and turn off when no one queries. A machine becomes disposable: if one dies, start another and point it at the same storage.

Name the parts. D is the data size. d is the data one machine's disk holds. Q is the number of machines the query load needs. With storage and compute together, you need Ncoupled machines.

Say it aloud

N-coupled equals the max of D over d, and Q.

Ncoupled
N-coupled the machines a database needs when each one stores data and runs queries.
max
the max of the larger of the two numbers. You must hold the data and serve the queries.
D
D the total data, in terabytes.
d
d the data one machine's disk holds, in terabytes.
Q
Q the machines the query load needs. A split system needs only these, plus storage billed per terabyte.
In plain words

Divide the data D by what one machine holds, d. Compare with the machines Q the queries need. Take the larger: that is N-coupled. A split system runs Q machines and pays for D terabytes of object storage.

With numbers

With made-up numbers: D = 100 TB, d = 4 TB and Q = 5. N-coupled = max(25, 5) = 25 machines. Split, it is 5 machines and 100 TB of storage. At illustrative prices of $1,000 a machine-month and $23 a TB-month: $25,000 against $7,300 a month.

Grow the data, not the processors

Warm squares are machines; a purple stripe is a local disk full of data. Grow the data, then the queries, then turn the query machines off at night.

100 TB
5

Illustrative prices: $1,000 per machine-month, $23 per TB-month of object storage, d = 4 TB per machine. Only split machines switch off; coupled machines hold the data, so they stay on.

The split costs latency. A read from object storage crosses the network and is far slower than a read from a local SSD. So query machines cache hot data on their own disks, and the first query after a restart is slow.

Failure. Symptom: every morning the first reports are slow, then speed up. Measure: the cache hit rate on query machines, and bytes read from object storage per query. Cause: the machines restarted overnight with empty caches. Fix: warm the cache with the morning's common queries, or keep one machine on.

D = 40 TB, d = 4 TB and Q = 12. How many machines does each design run?

Chapter 7

One Node or Many

Spread the data only for a reason, because many machines means something is always broken

One large server handles more than most apps ever need. So why spread a database over many machines, as a distributed system? The common reasons are these:

The price is that parts fail on their own. One machine either runs or not. With many, some machine is often down while the rest run. This is partial failure. Call the chance that one machine is down at a given moment p, and the number of machines n. The chance that at least one is down is Pany.

Say it aloud

P-any equals one minus, one minus p, to the n.

Pany
P-any the chance that at least one of the n machines is down right now.
1 −
one minus turns "all up" into "some down".
1 − p
one minus p the chance one machine is up. p is the chance it is down, 0.1% here.
n
to the n multiply once per machine, assuming machines fail independently.
In plain words

One machine is up with chance 1 minus p. Multiply that n times for all n to be up. One minus the result is the chance some machine is down. It is the same shape as the dual writes of Chapter 4.

With numbers

With made-up numbers: p = 0.001. For n = 1, P-any = 0.1%. For n = 100, P-any = 1 − 0.999100 = 9.5%. For n = 1,000 it is 63%: something is broken most of the time, so the software must expect it.

Watch a fleet fail in parts

Each square is a machine. Red means down right now. Grow the fleet and watch how often at least one square turns red.

100

Illustrative simulation: each machine fails and recovers at random and independently, down a fraction p of the time. Real failures are often correlated (one bad deploy, one power feed), which is worse.

Each call between machines also crosses the network, where it can be slow, lost or answered twice (Failure and Time, The Trouble with Distributed Systems). Microservices and serverless functions add many such calls; Service Architecture weighs them. The advice: stay on one node until a reason on the list forces you off it.

Failure. Symptom: a nightly job across 200 machines fails most weeks, though each machine fails only 1 night in 1,000. Measure: which machine broke each run; it is a different one each time. Cause: 1 − 0.999200 = 18% of runs lose some machine. Fix: retry the failed part, and checkpoint (Batch Processing).

Each machine is down 1% of the time, independently. With 50 machines, what is the chance at least one is down right now?

Chapter 8

Data, Law and People

Erase one person from every copy, and keep less data in the first place

Data systems hold facts about people, and the law sets rules for that. In the EU, the GDPR (General Data Protection Regulation) gives a person the right to have their personal data erased "without undue delay" when certain grounds apply (Article 17). Article 5 adds data minimisation: collect only what the purpose needs, and keep it no longer than needed.

Erasure is hard because of Chapter 4. A customer's address sits in the system of record, in every derived copy and in every backup. Deleting the row removes one copy of many. Article 17 even asks the company to tell others it shared the data with that the person wants it erased.

Count the copies of customer 42's address in our shop:

copies = 1 orders database + 3 derived copies + 30 daily backups = 34

Erase customer 42

The big box is the record, the teal boxes are copies derived from it, and the small boxes are backups. Pick an approach and press Erase. Red boxes still hold the address.

Illustrative shop. This is a design sketch, not legal advice; the rules differ by country and by the grounds for erasure.

Two designs help. First, derive every copy from the change log, so a deletion in the record flows to each copy like any other change. Second, encrypt each person's personal fields with a key kept only for that person. To erase them, delete the key; every copy, backups too, becomes unreadable. This is called crypto-shredding.

The cheapest data to protect is data you never kept. For each field, ask which question it answers, and drop the fields that answer none.

Failure. Symptom: a deleted account reappears after a database restore. Measure: does the restore step replay deletions made after the backup? Cause: the backup predates the deletion. Fix: keep a log of deletions and reapply it after every restore, or shred keys so old backups hold nothing readable.

Which approach makes customer 42's address unreadable in old backups at once, without editing each backup?

Chapter 9

Design the Shop's Data System

Make four choices for one workload and watch every cost move at once

Now put the trades together. Pick a workload, then make four choices: where analytics runs, how copies stay in step, where machines live, and how many database nodes there are. Each row of the desk uses the equation from its chapter, so you can trace every number.

No setting wins every row. A good design is the one whose losses this business can live with. Try the busy shop first: it needs fresh reports and has bursty traffic.

Set the four dials

Each bar is one cost. Green meets the workload's need, red misses it. Change one dial at a time and see which rows move.

Workload

Analytics runs on

Copies stay in step by

Machines live

Database nodes

Illustrative model built from Chapters 1 to 7, with their numbers. Writes fail 1 in 10,000 with k = 3, and a node is down 0.1% of the time. The cost row uses Chapter 5's prices for the app fleet only. Replicas assume automatic failover.

Two lessons fall out. First, the dials interact less than you fear: each row moves with one dial, which is why the chapters could be taught apart. Second, the right answer changes with the workload. The steady ledger pays less on its own machines, and the small shop does not need a warehouse at all.

Failure. Symptom: a design review picks "the best database" before naming the workload. Measure: can anyone state the order rate, the report freshness needed and the average utilization? Cause: the trade-offs have no numbers to weigh against. Fix: write the workload first, then set each dial against it.

For the busy shop (reports must be under 2 hours old, checkouts under 25 ms), where should analytics run?

Chapter 10

The Field Guide

Keep the numbers, the checklist and the code for your next architecture choice

A shop is several data systems. Keep the checkout's small reads by key on a row store, and move big scans to a column-store copy that is hours old. Feed every copy from one system of record through its change log. Rent machines while utilization is below the break-even, and own them above it. Spread over many nodes only for a reason, and expect some to be down. Remember that every copy of a person's data must be erasable.

Terms and numbers

TermWhat it isThis lesson's number
Scan timeT = n · w / B50 M × 200 B / 500 MB/s = 20 s
Column store readDcol = n · Σ wused50 M × 12 B = 600 MB, 16.7 times less
Queue at a busy diskR = s / (1 − ρ)3 ms: 4.3 ms at ρ 0.3, 30 ms at ρ 0.9
Warehouse data ageAmax = I + L24 + 1.5 = 25.5 h nightly; 1.25 h hourly
Dual-write driftP = 1 − (1 − p)k0.03% at p 1 in 10,000, k 3: about 13,000 a day at 500/s
Break-even utilizationu* = (P cown + F) / (P ccloud)0.89 at P 40; 0.41 at P 400 (illustrative)
Coupled machinesN = max(D / d, Q)max(25, 5) = 25 against 5 split
Partial failurePany = 1 − (1 − p)n9.5% at 100 nodes, 63% at 1,000 (p 0.1%)
Copies to eraserecord + derived + backups1 + 3 + 30 = 34

Checklist

  1. Write the workload first: order rate, report freshness, data size, average utilization.
  2. Keep transactions and big scans on different stores once scans hurt checkout latency.
  3. Name the system of record for every fact.
  4. Update copies from the record's change log, not with dual writes.
  5. Compute u* for your own fleet before choosing cloud or self-hosting.
  6. Split storage from compute when data grows faster than queries.
  7. Distribute only for a named reason, and design for partial failure.
  8. List every place personal data lives, backups included, and plan its erasure.

The core as code

python# the lesson's trade-offs as functions you can call with your own numbers
def scan_s(n, w, B):           return n * w / B                # T = n·w/B
def col_bytes(n, used):       return n * sum(used)            # D_col = n·Σ w_used
def disk_wait_ms(s, rho):     return s / (1 - rho)            # R = s/(1-ρ)
def max_age_h(I, L):          return I + L                    # A_max = I + L
def any_fail(p, k):           return 1 - (1 - p) ** k          # dual writes, or nodes down
def break_even(P, own, cloud, F): return (P * own + F) / (P * cloud)
def coupled(D, d, Q):         return max(-(-D // d), Q)       # ceil(D/d) vs Q

print(scan_s(50e6, 200, 500e6))             # 20.0 s on rows
print(col_bytes(50e6, [4, 8]) / 500e6)      # 1.2 s on columns
print(disk_wait_ms(3, 0.9))                 # 30.0 ms during a scan
print(max_age_h(24, 1.5))                    # 25.5 h, nightly ETL
print(any_fail(1e-4, 3) * 500 * 86400)       # ~12,959 drifted orders a day
print(break_even(40, 250, 700, 15000))       # 0.893
print(coupled(100, 4, 5))                     # 25 machines
print(any_fail(0.001, 100))                  # 0.095

Keep going

The takeaway. Every architecture choice moves a cost: from checkout latency to report freshness, from money to staff time, from simplicity to partial failure. Put a number on each side, and choose for the workload you have.

Now press Present or Teach and explain four things from memory: why a scan hurts checkouts, why columns help, why dual writes drift, and where u* comes from. Then go back to the hero and run the report all three ways.

Trade-Offs in Data Systems · following Designing Data-Intensive Applications, 2nd edition, Chapter 1
Next: Nonfunctional Requirements · Back to Gleams