Skip to content

Performance ​

Apple M4 Max. PostgreSQL and MySQL run in Docker on the same machine; SQLite writes to the local SSD with synchronous=NORMAL. Medians; see the benchmark code for ranges.

PostgreSQLMySQL 8.4SQLite (modernc)
Bulk insert, 10k jobs per call~250k jobs/s~77k jobs/s~300k jobs/s
Claim + finish, 50 per fetch~45k jobs/s~15k jobs/s~80k jobs/s
One server, 100 workers, no-op handler~21k jobs/s~6k jobs/s~70k jobs/s
Enqueue to handler startp50 3.3ms, p99 6.6ms~5–20ms with redisbus, PollInterval withoutp50 0.16ms in the same process

The MySQL numbers are dominated by commit latency on this setup (binlog with sync_binlog=1, 4-6ms per commit); a server with a faster disk will do noticeably better.

Compared with River v0.47 on the same PostgreSQL, alternating rounds between the two libraries (bench/):

ScenariokilnRiver (defaults)River (1ms fetch cooldown)
Bulk insert251k jobs/s134k (InsertMany), 222k (InsertManyFast)
8 goroutines inserting one job at a time5.1k jobs/s4.4k jobs/s
Drain 50k no-op jobs, 100 workers21.2k jobs/s1.0k jobs/s20.3k jobs/s
Drain 20k jobs with a 1ms handler19.9k jobs/s1.0k jobs/s13.7k jobs/s
Enqueue to handler start, p503.3ms55ms4.7ms

River's defaults fetch at most once every 100ms, which is what caps it around 1k jobs/s; with that cooldown lowered the no-op drain is a tie, and the p99 latency of the two was too noisy on this machine to call either way.

What kiln writes to PostgreSQL ​

Throughput says how fast the queue is; this says what it costs the database it shares with your application. 10,000 orders placed by 8 goroutines, each in a transaction that inserts the order and enqueues one job, with a server running the jobs. PostgreSQL 17, numbers per job on top of the order's own insert.

WAL writtenCommitsRows written
Jobs in PostgreSQL (pgstore)1,326 bytes2.44.2
Jobs in Redis, outbox in PostgreSQL387 bytes1, not waited for2
Jobs in Redis, enqueued directly000

cd bench && go run . -load reproduces it; Where jobs live explains the three setups.

Under a production-like load ​

The numbers above are single-purpose benchmarks. To see kiln in something closer to production, a small shop backend runs the same code on all four stores: PostgreSQL and MySQL with an API process and two workers, SQLite and memstore in one process. Placing an order writes it and, in the same transaction, enqueues a flow: a payment job under Limit{Max: 4, Rate: 20, Per: time.Second, Burst: 5}, then a confirmation e-mail and an invoice that wait for it. The payment gateway is a fake that rejects more than 20 requests per second or 4 at a time, fails 15% of charges and leaves PIX payments pending. Servers run with a 2s heartbeat, DeadAfter 15s and LeaderTTL 6s; MySQL polls every 200ms and has no bus.

v0.3.1v0.4.0
Busiest second at the gateway, 150 orders from 15 clientsup to 40 requests (429s)24–25 on every store, no 429
Same, with the limits row held for 1s mid-run (PostgreSQL)4025
Payment job, enqueue to start, MySQL p50684ms72ms
Continuation, parent done to child start, MySQL p5061ms46ms
Same two on PostgreSQL6ms / 5ms7ms / 6ms
Export resumed after its worker got kill -9, MySQL41s14s
Same with SQLite, where the one process restarts38s24s

Rescued jobs now restart within 100ms of being rescued; the rest of those times is noticing that the worker is gone (DeadAfter, plus LeaderTTL when the dead server was the leader). Across the runs, 25 buyers racing for 5 units of stock always ended with 5 orders, 20 rejections and no job left behind for a rolled-back order, and every charge reached the gateway exactly once.

Under chaos ​

soak/ runs worker processes against PostgreSQL or MySQL for as long as you ask, while it kills them with SIGKILL, stops them with SIGTERM and restarts the database, then checks that every job reached a final state, none ran more than its attempts plus the runs cut short, limits and rates held, and the store needs no repair. The jobs mix plain ones, retries, jobs that always fail, fan-in flows that read their parents' outputs, slow jobs, and jobs under a mutex, a Max, a Rate and both.

A 15 minute run on PostgreSQL, 4 workers, 50 enqueues per second:

Jobs57,211
Chaos31 SIGKILLs, 22 SIGTERMs, 3 database restarts of about 1.5s
Jobs lost0
Jobs run more often than allowed0
Peak concurrency per limited keyat or under its Max
Store after the runlimit counters at 0, nothing for Sweep to repair

A 24 hour run on PostgreSQL 17, 4 workers, 20 enqueues per second, on a 2 vCPU / 2 GB DigitalOcean droplet with kiln v0.8.0:

Jobs2,233,828
Chaos2,886 SIGKILLs, 2,139 SIGTERMs, 360 database restarts
Jobs lost0
Jobs run more often than allowed0
Orphaned jobs rescued after a SIGKILL2,307
Peak concurrency per limited keyat or under its Max, over about 85,000 runs each
Starts per window on the Rate keysat most 6 of 8 allowed in 1s, 32 of 34 in 10s
Store after the runlimit counters at 0, nothing for Sweep to repair, drained in 7s
Memory of the harness and its 4 workers44 to 58 MB across the 24 hours

The workers logged store errors around each database restart (claims, heartbeats, leases), as expected; none of them cost a job.

The same harness with the jobs in Redis and the enqueues going through an outbox in PostgreSQL (-backend redis), 15 minutes, 4 workers, 50 enqueues per second, Redis with its append-only file on:

Jobs58,067
Chaos32 SIGKILLs, 24 SIGTERMs, 4 restarts of Redis
Jobs lost0
Jobs run more often than allowed0
Peak concurrency per limited keyat or under its Max
Enqueues attempted while Redis was restarting20, all rolled back with their transaction
Store after the runlimit counters at 0, nothing for Sweep to repair, drained in 17s

An enqueue through the outbox needs Redis for a moment, to check the job and give it an id, so the 20 transactions that met a restarting Redis failed as a whole and left nothing behind, in either store.

cd soak && go run . -duration 24h -rate 20

soak/vps runs the same thing on a server with nothing but Docker: a compose file with its own PostgreSQL, which keeps the summary, the worker logs, CPU and memory every 5 minutes and a dump of the database in soak/vps/evidence.

See soak/README.md for the flags. -container none skips the database restarts when other tests share the database.

Released under the MIT License.