Measured results

Local numbers, not production numbers. Apple M4, 10 cores, a local SQLite Durable Object; load generator and server on one machine. They come from the automated tests in the code repository, on the same storage engine this demo uses. The live demo holds a much smaller dataset.

Data

Legacy import300,000 codes (plus 500 duplicate rows) in 7.1 s, reconciled row by row with the source
Same import again0 inserted, 3.5 s
New codes100,000 generated beside the 300,000 in 1.2 s, 0 collisions

Simultaneous checks

One code, 200 at once1 genuine, 199 already verified, 0 failed; 675 requests/s, p95 293 ms
2,000 codes, 3 tries each2,000 genuine, 4,000 already verified, 0 failed; 832 requests/s, p95 343 ms

Why one write decides

UPDATE codes SET status = 'used' … WHERE code = ? AND status = 'unused'

The test of the status and the change are one statement, so a second check cannot slip between them. The database is one SQLite-backed Durable Object with one thread; the write and its log entry commit in one transaction, and the reply is sent only after they are durable. The database also refuses to change a used code.

A control test runs the unsafe read-then-write version: all 200 simultaneous checks are told "genuine".

Back to the code check