Qendrim Beka

Durable Webhook Delivery

0ledger rows

Sender says
Attempts

Recorded +0 ms

Details

A receiver records an expense, then the response is lost. The sender cannot tell this from a request that never arrived, so it has to try again. Retry blindly and the expense is recorded twice. Do not retry and it can be lost.

No sender can solve this alone. So this project defines what a receiver must do, builds both sides, and then tries to break them on purpose.

Results

A clean result only means something if the test could have failed. So each claim below is paired with a control that must fail. The plan was committed before the runs, and the tests that failed are shown here too.

30 minutes at 1,000 events per second
p99 63 to 71 ms, 1,800,000 effects reconciled250 ms budget
2,000 per second, 60 second runs
p99 86 to 94 ms with 4 workers2,500 per second failed the rule
2,000 per second, ten minute runs
Failed twice, with a p99 of 1,099 to 1,497 ms and then 378 to 3,881 ms, though all 7,200,000 effects reconciled250 ms budget
75 workers killed on purpose, 185,200 deliveries
0 repeated, 0 missingNaive receiver: 50 of 50 planted repeats found
100,000 events, 20,000 duplicates, 30 crashes
0 repeated, 0 missingNaive receiver: 50 of 50 planted repeats found
5 primary failovers
0 acknowledged events lostAsync replication lost 196 to 273
Slow destination isolation
Passed its retest at a p99 of 58 to 67 ms, after the first attempt failed at 59 to 642 msLimits off: 34,899 to 36,945 ms
Lease protocol, TLA+
9,484,492 states, no violation4 of 4 broken designs caught
Test suite
39 of 39 mutants caughtEach mutant removes one rule

The outage

One destination turned slow for 60 seconds while another tenant kept sending. This is the median of three retest runs. Per-destination limits held the healthy tenant's p99 at 61 ms. With them removed it reached 36,317 ms, about 599 times worse. The failing destination caught up 25 seconds after it recovered. The first attempt at this test missed the 250 ms budget in 2 of 3 runs, because of one second stalls that also hit before the outage began.

How it holds

Commit first
Nothing is sent before it is durable A worker commits its lease before the request leaves, so a crash at any line can be recovered.
Lease tokens
A late worker cannot change anything Each claim gets a new token. A worker that wakes after its lease ended is recorded, and ignored.
Delivery keys
One key, across every retry The receiver commits the key and the expense in one transaction, so a resend finds the key and writes nothing.
Isolation
One bad destination stays contained Limits are derived from leased rows, so a crash cannot leave them wrong, and a breaker stops wasted attempts.
Failover
An acknowledged event outlives its primary With synchronous replication, ingress answers only after the standby has the commit.

Limits

  • All numbers were measured on one Apple M5 Pro Mac, with PostgreSQL 17 flushing the drive cache on every commit. The load generator, engine, receiver and databases shared that machine and one drive, and other work ran on it too.
  • The cause of the stalls at 2,000 per second was not found. A drive flush probe stayed fast through the retest, so a slow flush does not explain them there. A rate that holds for 60 seconds and fails at ten minutes is a real finding.
  • The fault model is process death, lost responses and pauses. Power loss was not tested, and the failovers share one machine, so they say nothing about a data centre failure. Promotion is triggered by the harness, with a declared 2 second detection time.
  • The crash and the naive case are different faults, so their retry times should not be compared. The naive case is the receiver's log for one event, which holds no worker or sender times, and its amount comes from the run's seed.
  • The kill has no timestamp of its own, so the lost acknowledgement sits between two recorded steps. The stage stretches the first milliseconds and shortens the waits, while its clock shows recorded time.
  • This is an offline replay of recorded runs. All data is synthetic.

Method

The plan, the runs and every failed test are in the report, and the results are in the repository.

Recordings

Every step of the crash
+0 ms, engine
event evt-2026-266 and its delivery committed, then ingress answered 202
+10 ms, worker
worker-7 committed lease e9922f45 for attempt 1 before sending
+32 ms, receiver
attempt 1: key and expense committed together
+3.09 s, engine
lease e9922f45 expired with no report from worker-7
+6.71 s, worker
worker-17 committed lease b975bc0c for attempt 2 before sending
+6.72 s, receiver
attempt 2: key already present, no new effect
+6.72 s, worker
attempt 2 recorded as success with status 200
Every step of the naive case
+42 ms
attempt 1: expense written
+42 ms
attempt 1: response dropped after the write
+81.49 s
attempt 2: expense written
The outage, second by second
SecondHealthy queueFailing queuep50 msp99 msEvents
1141137.352.1308
2131039.754.5289
3221740.154.2303
491135.847.0279
5141334.847.9292
6131839.761.4301
7141637.453.5310
8122237.347.9296
910735.951.2285
10141438.957.9274
11201735.045.7318
12221035.646.6300
1317937.552.9299
14121336.151.9294
15181535.549.7266
16142135.649.3297
17131437.753.8286
18131635.347.5277
19121035.645.5313
2020838.353.0309
211316034.446.3295
22946334.348.7289
231174635.249.8267
249104235.350.1266
2511136235.051.1308
2614168234.447.4310
277200736.951.3280
289233438.554.5266
2912261436.451.3307
304289236.452.6272
318319939.159.3290
3217350936.450.3302
3313382236.551.1291
3416412837.650.2301
3519440940.057.7319
3610470137.154.4304
377499734.149.4322
3815527940.462.5320
3916559933.251.9276
4020589233.946.8319
4116614833.445.1291
429646138.067.7299
4311675637.551.6303
4410706634.355.8276
4515736636.552.0279
4622763344.978.1292
4718795633.648.3299
489825535.649.1302
4920855439.458.3282
5011882236.348.8291
5116912234.151.9303
5224940635.248.5315
5312968235.448.9285
546996632.649.4257
55131025534.048.9288
56141054240.165.1292
57151084038.855.1278
5831117338.455.4301
59151144739.156.0295
60201178140.766.6316
61171207439.458.6332
62151236737.254.9311
63221267641.061.0323
64121298941.765.2313
65141327239.463.6266
66161357844.370.3296
67121386746.674.7288
68191417344.969.9316
69111446038.152.1274
7041478938.555.6317
71141510341.960.2292
72181539839.563.2293
73111569936.451.1307
74111597939.355.1304
75131629339.861.4298
76101656738.656.4321
7781685840.163.8280
78131714344.864.0318
79101742442.463.7308
80161770336.251.4281
81111801637.454.1301
82251832537.252.5313
83131861336.349.8288
84131890038.854.0319
85121796244.365.6265
86181714641.769.5321
87141628540.965.5279
8881537543.464.0292
89111454342.159.7283
9081354039.153.2296
91131252640.155.6264
92251163142.063.9296
93151073941.456.5312
9416985540.853.9275
9511889341.855.8306
9622803543.762.2305
9713716443.563.6328
988638244.262.2322
9910542438.755.5321
10015446437.653.0314
10118346936.247.0318
102023500.00.00
10309670.00.00