Durable Objects · Exercise 02

No lost updates

Send 50 simultaneous increments to your Durable Object counter and to a KV-based counter, and see which one loses updates.

No lost updates

Counting sounds easy until lots of people count at once. Two requests read the same value, both add one, both write it back, and one of the updates is gone. Most databases fix this with transactions and locks you have to remember to use.

In this exercise you’ll race two counters against each other: the Durable Object from the last exercise, and the same logic written with Workers KV.

What you’ll build

A second counter route backed by KV, then a burst of 50 simultaneous requests at each. Your agent compares what comes back. One of them ends at exactly 50.

Prerequisites