Performance
Measured throughput for a fixed profile, claim cost against millions of delivery rows, many workers under faults, and a 72-hour soak, with methods and caveats.
These numbers come from pnpm benchmark, pnpm benchmark:history, and pnpm test:chaos:contention in the repository. They show what the library costs on its own, not a capacity guarantee for your receivers, network, or database. The 72-hour soak ran on the hosted Playground instead.
Profile: 20 endpoints in separate scopes, 5,000 events (one delivery each), 2 worker processes with concurrency: 32, a per-endpoint cap of 8, 20 pool connections per process, and a local receiver that verifies the signature and answers 204 after 5 ms. Every event is published, each in its own transaction, before the workers start.
Results
Measured on 12 October 2026 on an Apple M3 Pro (12 cores, 18 GB) with Node.js 24.21 and PostgreSQL 16.15 in Docker on the same machine. Middle of three runs:
| Measurement | Result |
|---|---|
| Publish rate | 3,350 events/s |
| Drain rate, 5,000 queued deliveries | 1,550 deliveries/s |
| Attempt latency, claim to recorded outcome | p50 17 ms, p95 23 ms, p99 28 ms |
| Time in queue, publish to success | p50 2.5 s, p95 3.2 s, max 3.4 s |
| Attempts | 5,000 succeeded, 0 retried, 0 abandoned |
Time in queue reflects the backlog: the median event waited for half of it. With workers already running, a single event waits about the attempt latency plus the poll interval.
What the numbers do not say
- Receiver time dominates in production. With a 300 ms receiver, throughput depends on
concurrencyandmaxInFlight, not on the library. - One machine. Everything shares CPU. Separate hosts mean less contention and more network latency.
- No failures. Retries, timeouts, and lease recoveries are slower by design.
- Empty tables. This profile starts empty. Large history measures claims against millions of rows.
Large history
Claims stayed in the low milliseconds from an empty table to 7 million deliveries. prune() did not on schema 6: one call slowed down as history grew, because no index served the replay_of foreign key's cascade. Schema 7 adds that index (#153).
Method: pnpm benchmark:history seeds succeeded deliveries by SQL in stages, each with one event and one attempt, spread over the 20 scopes of the profile and over the last 10 days. 30% of them are older than the default seven-day retentionMs, so prune() always has work. After each stage it runs VACUUM (ANALYZE), a discarded warm-up, then the profile's live phase of 5,000 deliveries with prune() idle. It then times one prune() call on its own pool with a 120 s statement timeout.
Claim timings are pg_stat_statements means of server-side execution time over each live phase. Each phase runs about 160 endpoint picks and 640 delivery picks. They exclude network and pool wait.
Measured on schema 6 on 2 November 2026 on the same machine as above, with PostgreSQL 18.6 in Docker. One run per size:
| Deliveries in the table | 0 | 1.0 M | 3.0 M | 7.0 M |
|---|---|---|---|---|
| Deliveries table and indexes | 0.08 MB | 0.76 GB | 2.27 GB | 5.28 GB |
| Endpoint pick, mean | 1.17 ms | 0.61 ms | 1.05 ms | 1.13 ms |
| Delivery pick, mean | 0.28 ms | 0.14 ms | 0.30 ms | 0.24 ms |
| Reserve update, mean | 0.68 ms | 1.44 ms | 2.48 ms | 1.84 ms |
| Lease recovery scan, mean | 0.01 ms | 0.02 ms | 0.03 ms | 0.02 ms |
| Attempt latency, p95 | 29 ms | 35 ms | 46 ms | 33 ms |
| Drain rate | 1,275/s | 1,133/s | 896/s | 1,041/s |
One prune() call | nothing due | 2.65 s | 12.2 s | 50.3 s |
The endpoint and delivery picks read only partial indexes on pending and in-flight rows, so history does not reach them. The reserve update grew with history, from under 1 ms to about 2 ms; this run does not show why. Drain rate moved with the machine's other load, not with history size.
A prune() call deletes up to 100 events and cascades to their deliveries. For each deleted delivery, PostgreSQL looks for replays that point at it, and with no index for that lookup it scans the scope's deliveries. At 7 million rows the lookup became a parallel full scan. A prune() loop running beside the workers at 1 million rows exceeded a 10 s statement timeout. While it ran, it also held locks that slowed claims.
With the schema 7 index
The last experiment added CREATE INDEX ON webhook_deliveries(scope_key, replay_of) WHERE replay_of IS NOT NULL at 7 million rows, the index schema 7 ships. It then ran the live phase with prune() looping back to back, the shape of the shipped cleanup entry point:
| Measurement at 7.0 M | Schema 6, prune idle | With index, prune looping |
|---|---|---|
One prune() call | 50.3 s | 0.06 s |
prune() calls in the phase | none | 424 |
| Events pruned in the phase | none | 30,432 |
| Endpoint pick, mean | 1.13 ms | 1.50 ms |
| Reserve update, mean | 1.84 ms | 1.49 ms |
| Attempt latency, p95 | 33 ms | 34 ms |
| Drain rate | 1,041/s | 956/s |
With the index, claims stayed flat while prune() deleted events beside them. On schema 6, run cleanup off-peak or upgrade to schema 7.
Caveats:
- One run per size on a busy machine. Other work kept the load average between 5 and 27, and Docker had 4 CPUs and 4 GB.
- One shape of history. Every seeded delivery succeeded on its first attempt, with no failures and no replays. Claims do not read those rows, but
prune()does. - Measured before it shipped. The run added the index by hand; schema 7 ships the same definition.
Many workers under faults
The contention run drains 20,000 events through one scope with 8 or 32 worker processes while faults hit them. Each worker has concurrency: 16, an 800 ms timeout, a 2 s lease, and 10 pool connections. The scope holds 8 endpoints with a cap of 16 in flight each: six answer 204, one answers 503 to the first request per event, and one never answers the first request per event.
Three faults land during the drain:
- At 10% drained, PostgreSQL terminates every worker connection.
- At 30%, two workers are killed with
SIGKILLmid-send. - At 50%, a transaction holds an exclusive lock on the deliveries table for 2.5 s.
A supervisor restarts every worker that exits, as a process manager would. One run per worker count, measured on 2 November 2026 on the same machine as above with PostgreSQL 18.6 in Docker:
| Measurement | 8 workers | 32 workers |
|---|---|---|
| Drain time | 41.0 s | 40.2 s |
| Drain rate | 488/s | 497/s |
| Attempts succeeded | 20,000 | 20,000 |
| Attempts retried | 1,978 | 1,976 |
| Attempts abandoned | 64 | 94 |
| Receiver requests | 22,042 | 22,070 |
| Worker restarts | 18 | 65 |
| Most in flight per endpoint | 16 of 16 | 16 of 16 |
| Oldest expired lease seen | 0 ms | 208 ms |
| Endpoint pick, mean | 1.77 ms | 2.62 ms |
Eight workers already fill every endpoint's cap, so 32 workers did not drain faster. The faults and the failing receivers set the pace. Abandoned attempts are sends whose worker died or lost its connection before recording an outcome; each was recovered and retried. The 8-worker run saw a load average near 12 from other work on the machine, the 32-worker run near 5.
Every invariant is checked against the database after the drain, and the run fails if any does not hold:
| Invariant | 8 workers | 32 workers |
|---|---|---|
| No lost event | Held | Held |
| No delivery stuck | Held | Held |
| Every attempt recorded | Held | Held |
| No double delivery | Held | Held |
| In-flight cap respected | Held | Held |
- No lost event. Every published event has one delivery, every delivery ends
succeeded, and the receiver saw every event. - No delivery stuck. Nothing is in flight at the end, and no expired lease outlived 5 s during the drain. That bound covers recovery after the 2.5 s lock, not steady state, where recovery takes tens of milliseconds.
- Every attempt recorded. Each delivery's attempts are numbered 1 to its attempt count, none is left open, exactly one succeeded, and it is the last.
- No double delivery. The receiver logs every request with the database clock. Each request falls inside exactly one attempt's window, from its row insert before sending to its recorded outcome, and no attempt window holds two requests.
- In-flight cap respected. A sampler reads in-flight rows per endpoint every 250 ms, and the receiver counts open requests per endpoint. Neither exceeded 16.
The run took only one schedule of faults, at one load. A delivery in flight through all three faults plus a failing receiver could exhaust its five attempts and fail the run, which is unlikely but possible.
72-hour soak
The soak ran good-webhooks 0.7.0 on schema 7 in the public Playground for 72 hours. It started on Monday 2 November 2026 at 09:56 and ended on Thursday 5 November at 10:00, Athens time. The Playground runs on Railway as a web service, a worker service, and PostgreSQL 18.6. Each of these receivers got one event per 5-minute tick for the whole run:
| Receiver | Behavior |
|---|---|
| canary | 204 |
| demo | 204 |
| flaky | 500 on 30% of requests |
| slow | 12 s on 20% of requests |
| busy | 429 on 25% of requests |
| failing | 500 |
| gone | 410, endpoint paused |
The soak found no library defect.
Faults
Twelve faults restarted a service through the Railway API: 8 worker restarts and 4 PostgreSQL restarts. Each fired 8 s after a 5-minute tick, while an attempt to the slow receiver could still be in flight. No attempt was abandoned, so no restart cut off a send; the contention run covers kills mid-send. PostgreSQL logs confirm each restart: a fast shutdown, then accepting connections again in about 1.5 s.
| Time (Athens) | Restarted |
|---|---|
| Mon 17:00 | PostgreSQL |
| Mon 19:35 | Worker |
| Tue 03:20 | Worker |
| Tue 07:05 | PostgreSQL |
| Tue 11:45 | Worker |
| Tue 21:10 | Worker |
| Wed 01:25 | PostgreSQL |
| Wed 08:30 | Worker |
| Wed 13:10 | Worker |
| Wed 17:55 | Worker |
| Wed 23:50 | PostgreSQL |
| Thu 05:40 | Worker |
- Canary resumed. The canary arrived on its next scheduled tick after every fault, with no tick late or retried.
- Health.
/api/healthanswered200and healthy on every poll in the 10 minutes after each fault. - Nothing left in flight. Of 36 checks at 2, 10, and 30 minutes after each fault, 33 found nothing in flight.
- Two found one attempt in progress, after the Wednesday 13:10 and 17:55 faults, and the next sample showed none.
- One, 10 minutes after the Tuesday 21:10 fault, got no response on the polling machine.
Invariants
These checks read the Playground's status page, so they are lighter than the contention run's.
- No lost event. Canary and demo each had 288 deliveries succeed and none fail in every 24 hours.
- No delivery stuck. Each daily snapshot showed nothing in flight and no attempt in progress.
- No attempt abandoned. Every check after a fault showed 0 abandoned attempts in the last hour.
- No double delivery. Every canary and demo delivery succeeded on its first attempt, with no retry.
Retries to the slow, flaky, and busy receivers repeat requests by design, so the lost and double delivery checks cover canary and demo only.
Daily snapshots at about 10:00 on Tuesday, Wednesday, and Thursday each counted 288 ticks for canary and demo, one per 5 minutes. A sampler also read the demo receiver's latest deliveries every 20 minutes and saw 854 of the 864 ticks, each delivered once on its first attempt. It missed the 10 ticks from Tuesday 17:00 to 17:45, during an outage of the polling machine, and the daily counts cover them.
The oldest pending delivery stayed at 168 to 169 hours. The paused gone receiver queues one delivery per tick, and hourly pruning removes them at the 7-day retention.
Health polling
A separate machine polled /api/health every 30 s, 8,427 times in all. None returned an HTTP error, but 171 got no response, in a few blocks of up to 68 minutes. The Playground kept delivering through each block, which points to outages on the polling machine, so these polls do not measure availability.
The soak used light, steady traffic and one fault schedule. It shows that 0.7.0 recovers on its own from restarts, not how fast it drains.
Run it yourself
export TEST_DATABASE_URL='postgres://postgres:webhooks_dev_only@127.0.0.1:55439/webhooks'
pnpm benchmarkThe script runs in a temporary schema, prints a JSON report, and fails if any delivery does not succeed exactly once. Edit scripts/benchmark/config.mjs to model your own receiver delay or concurrency, and compare runs on the same machine only.
The large-history and contention runs need more from the server. Start PostgreSQL with pg_stat_statements and enough connections for 32 workers:
docker run --name good-webhooks-proof \
-e POSTGRES_PASSWORD=webhooks_dev_only \
-e POSTGRES_DB=webhooks \
-p 127.0.0.1:55440:5432 \
-d postgres:18 \
-c shared_preload_libraries=pg_stat_statements \
-c max_connections=600 \
-c shared_buffers=1GB
psql 'postgres://postgres:webhooks_dev_only@127.0.0.1:55440/webhooks' -c 'CREATE EXTENSION pg_stat_statements'
export TEST_DATABASE_URL='postgres://postgres:webhooks_dev_only@127.0.0.1:55440/webhooks'
pnpm benchmark:history
CHAOS_WORKERS=8 pnpm test:chaos:contention
CHAOS_WORKERS=32 pnpm test:chaos:contention