Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
CAP is the most quoted and least useful thing in this field, because the version most people carry around — pick two of three — is not what the theorem says and does not describe any decision you will actually make. Partitions are not something you choose; they are something the network does to you, so the real choice is only what to do during one, and that choice comes up a few times a year. The choices you make every single day are the ones CAP does not mention: whether to answer this read from the nearest possibly-stale copy or pay a coordination round trip to be certain, whether to run one copy or three, whether to buy 30 percent headroom or 300. Naming a tradeoff precisely is what turns it from an argument into a decision, because once it has a name it has a price, and once it has a price you can ask whether it is worth paying. This task gives you names and prices for the four you will meet constantly.
CAP, corrected: PACELC. If there is a Partition, choose Availability or Consistency. Else — meaning on every ordinary day, which is nearly all of them — choose Latency or Consistency. The else branch is the one you live in, and it is missing from the popular version of CAP entirely. DynamoDB and Cassandra are PA/EL systems: available during partitions, fast the rest of the time, and you accept staleness in both cases. Spanner is PC/EC: it refuses rather than diverge, and it pays a coordination round trip on every strongly consistent read for the rest of its life. Neither is better. They have different prices.
Latency versus consistency, with a real price tag. In DynamoDB a strongly consistent read costs exactly twice as much as an eventually consistent one — one read capacity unit versus half of one — and it must go to the leader replica, so it is slower and it is unavailable if that leader is unreachable. That is not a metaphor; it is the rate card. At the photo app's 104 reads per second the difference is a few dollars a month and you should simply buy strong consistency everywhere. At 100x that same choice is a few hundred dollars a month plus a latency and availability penalty on every read, and now it deserves a conversation. The same tradeoff is free at one scale and load-bearing at another, which is why estimation comes before tradeoffs.
Cost versus redundancy, priced as multipliers. One availability zone is 1x and dies with the zone. Multi-AZ with a synchronous standby is roughly 2x the database bill and survives a zone. Multi-region active-passive is roughly 2x again plus cross-region transfer and a promotion procedure you must actually rehearse. Multi-region active-active is 2x plus conflict resolution, which is a permanent tax on your engineering time rather than your invoice. Say the multiplier out loud. A design that quietly assumes 4x infrastructure spend for a business that cannot afford 2x is not a design.
Simplicity versus headroom. Every component you add to survive a future 10x is a component you operate today, on a four-person team, at 3 a.m. The honest question is not can this scale, it is what will this cost me every week between now and the day it needs to. A single Postgres box with a good backup story and 5x headroom beats a five-service event-driven architecture with 500x headroom for almost every system that exists, right up until the day it does not — and the design skill is knowing roughly when that day arrives, and what the migration looks like.
# consistency_price.py — the latency/consistency tradeoff has a rate card.
# DynamoDB: an eventually consistent read costs 0.5 RCU, a strongly
# consistent read costs 1.0 RCU. Same data. Exactly 2x.
USD_PER_RCU_HOUR = 0.00013 # provisioned capacity, order of magnitude
HOURS_PER_MONTH = 730
INR_PER_USD = 88
def monthly(read_rps, strong):
rcu = read_rps * (1.0 if strong else 0.5)
usd = rcu * HOURS_PER_MONTH * USD_PER_RCU_HOUR
return rcu, usd
for rps, label in ((104, "today"), (10_400, "at 100x")):
ev_rcu, ev = monthly(rps, strong=False)
st_rcu, st = monthly(rps, strong=True)
delta = st - ev
print(f"{label:>9} {rps:>6,} rps "
f"eventual ${ev:>8,.0f} strong ${st:>8,.0f} "
f"delta ${delta:>8,.0f} / Rs {delta * INR_PER_USD:>10,.0f}")
# today 104 rps eventual $ 5 strong $ 10 delta $ 5 / Rs 434
# at 100x 10,400 rps eventual $ 494 strong $ 987 delta $ 494 / Rs 43,436
#
# Same decision, two scales. At 104 rps, buy strong consistency and stop
# thinking about it. At 10,400 rps it is a real line item AND it adds a
# leader round trip to every read. Estimate first, then choose.python3 main.py