// case study
distributed job queue
a durable single-node job queue in c++ with sqlite storage and lease-based retries.
- role
- solo
- year
- 2026
- status
- built, not deployed
- c++
- sqlite
- posix sockets
what it is
a durable job queue written in c++. clients enqueue jobs over tcp, workers claim them, and everything lives in sqlite.
TODO: why build it, and why sqlite.
delivery: at-least-once, with leases
workers claim jobs with a lease. if a worker disappears, the lease expires and the job goes back to the pool. failed jobs retry with exponential backoff, and repeated failures move to a dead-letter queue.
TODO: lease length, what "claim" looks like in sql, why at-least-once and not exactly-once.
letting sqlite do the locking
concurrency safety is handed to sqlite's file locking, in wal mode. it's a single-node design.
TODO: how the claim query works, and how you tested for double-claims.
the bottleneck wasn't the network
profiling showed per-commit fsync, not networking or threads, as the throughput bottleneck.
TODO: how you found it, what "relaxed" means here, and the tradeoff you picked.
two bugs worth writing down
- a slow query, diagnosed with
explain query plan. a compound index was replaced with two partial indexes. - a stale-lease race, fixed with a fencing token in the ack/nack protocol
TODO: what each one looked like when it happened.
kill -9
TODO: the crash-testing harness, what it covered, and what "acknowledged" guarantees.