Distributed

Lesson 02.2

Atomic conditional writes

An atomic conditional write checks a rule and applies the update as one indivisible database operation, leaving no gap for another request to interfere.

One step, no gap

A cookie shop's computer shows how many cookies are left. Right now it says 1 🍪. Two workers, Ava and Ben, each get an order at almost the same moment.

Last time, both workers sold the same last cookie, because one checked in the gap between the other's 👀 and ⌨️. So the shop makes a new rule: checking and updating happen in one step ✨.

In this lesson you'll

  1. 1Watch the new one-step rule on a normal day.
  2. 2Guess what happens when both workers are quick.
  3. 3Try your hardest to break it.