ContentsThe library

Doing Two Things at Once

The Problem You Decide Not to Have

Last timeWhy More Workers Stop Helping

Every technique in this course manages a shared piece of state. The cheapest option is to arrange that nothing is shared, and to pay the costs that choice brings instead.

Seven lessons have been about managing a shared piece of state. This one is

about the move that makes the previous seven unnecessary, and about why it is not

free.

The observation behind it is simple. Every cost in this course, the waiting, the

cycles, the aborted attempts, the ceiling, arises from two workers wanting the

same thing. If no two workers ever want the same thing, none of those costs

exists. So the first question about a contended resource should not be which

technique to apply to it, but whether it needs to be shared at all.

One owner for each piece

The standard move is to split the state by some key and give each piece exactly

one owner. A request is routed to the owner of the key it concerns, and that

owner handles it alone.

FIG 1Routing by key, so that no two workers touch the same state
Compare this with the guarded region from the second lesson. There, many workers took turns inside one region. Here each worker has its own region that nobody else may enter, so taking turns is not a thing that happens.

The waiting is not abolished, it is converted. Instead of workers contending for

a lock, requests queue for an owner. That is a real improvement rather than a

relabelling, because a queue is a well behaved object. It has a visible length

you can alarm on, a bounded capacity, a first-in order, and no possibility of a

cycle, a lost wakeup or a priority inversion. The entire family of failures from

the middle of this course is designed out along with the sharing.

The lesson stops here

6 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01The Update That Vanished
  2. 02A Door That Admits Oneopening only
  3. 03The Bill Arrives as Latencyopening only
  4. 04Everybody Holding, Nobody Movingopening only
  5. 05Try, Check, Try Againopening only
  6. 06The Promise Is Weaker Than You Thinkopening only
  7. 07The Ceiling You Cannot Buyopening only
  8. 08The Problem You Decide Not to Haveyou are here

Read alongside