Skip to Content

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:

MeasurementResult
Publish rate3,350 events/s
Drain rate, 5,000 queued deliveries1,550 deliveries/s
Attempt latency, claim to recorded outcomep50 17 ms, p95 23 ms, p99 28 ms
Time in queue, publish to successp50 2.5 s, p95 3.2 s, max 3.4 s
Attempts5,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 concurrency and maxInFlight, 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 table01.0 M3.0 M7.0 M
Deliveries table and indexes0.08 MB0.76 GB2.27 GB5.28 GB
Endpoint pick, mean1.17 ms0.61 ms1.05 ms1.13 ms
Delivery pick, mean0.28 ms0.14 ms0.30 ms0.24 ms
Reserve update, mean0.68 ms1.44 ms2.48 ms1.84 ms
Lease recovery scan, mean0.01 ms0.02 ms0.03 ms0.02 ms
Attempt latency, p9529 ms35 ms46 ms33 ms
Drain rate1,275/s1,133/s896/s1,041/s
One prune() callnothing due2.65 s12.2 s50.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 MSchema 6, prune idleWith index, prune looping
One prune() call50.3 s0.06 s
prune() calls in the phasenone424
Events pruned in the phasenone30,432
Endpoint pick, mean1.13 ms1.50 ms
Reserve update, mean1.84 ms1.49 ms
Attempt latency, p9533 ms34 ms
Drain rate1,041/s956/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:

  1. At 10% drained, PostgreSQL terminates every worker connection.
  2. At 30%, two workers are killed with SIGKILL mid-send.
  3. 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:

Measurement8 workers32 workers
Drain time41.0 s40.2 s
Drain rate488/s497/s
Attempts succeeded20,00020,000
Attempts retried1,9781,976
Attempts abandoned6494
Receiver requests22,04222,070
Worker restarts1865
Most in flight per endpoint16 of 1616 of 16
Oldest expired lease seen0 ms208 ms
Endpoint pick, mean1.77 ms2.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:

Invariant8 workers32 workers
No lost eventHeldHeld
No delivery stuckHeldHeld
Every attempt recordedHeldHeld
No double deliveryHeldHeld
In-flight cap respectedHeldHeld
  • 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:

ReceiverBehavior
canary204
demo204
flaky500 on 30% of requests
slow12 s on 20% of requests
busy429 on 25% of requests
failing500
gone410, 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:00PostgreSQL
Mon 19:35Worker
Tue 03:20Worker
Tue 07:05PostgreSQL
Tue 11:45Worker
Tue 21:10Worker
Wed 01:25PostgreSQL
Wed 08:30Worker
Wed 13:10Worker
Wed 17:55Worker
Wed 23:50PostgreSQL
Thu 05:40Worker
  • Canary resumed. The canary arrived on its next scheduled tick after every fault, with no tick late or retried.
  • Health. /api/health answered 200 and 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 benchmark

The 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

On this page