This lab runs on a free Appwrite project. No real cards are charged.

Tap Pay 100 times. Get charged once.

Two real races on Appwrite. Each button sends 100 requests at the same moment to two Appwrite Functions. One side runs the code most developers write. The other runs doubletap.

npm install appwrite-doubletap

1. Someone taps Pay 100 times

Both functions ask "has this order been paid?" before charging. One checks and then writes. The other wraps the charge in doubletap.

Without doubletap

read order, if unpaid, charge

Cards charged
0
Requests finished
0 of 100

With doubletap

dt.once(orderId, charge)

Cards charged
0
Requests finished
0 of 100

Each line is one request, from when the function started to when it answered. it read the order and saw no charge. it charged the card. it got back the first charge instead of making a new one.

2. 100 workers grab the same job

A background job should run on exactly one worker. The left side uses an Appwrite transaction: read the job, and if nobody holds it, take it and commit. The right side uses a doubletap lease.

Appwrite transaction

read job, if free, take it, commit

Workers who think they own the job
0
Workers finished
0 of 100

With doubletap

dt.lease(jobId)

Workers who think they own the job
0
Workers finished
0 of 100

Each line is one worker. it committed and believes it owns the job. it was refused. More than one red dot on the left means two workers run the same job at once.