Double-entry accounting at scale
summary
Relational ledgers hit a hard throughput wall because row-level locks limit updates to about 25 requests per second on a hot account; proof comes from Locust-driven tests against Postgres. The solution builds an API that writes entries immediately, tags them with account versioning, then batches additive entries via AWS SQS pollers into a single UPDATE per account. Idempotency uses a processed_entry table; median queue roundtrips are ~300–400ms (99th ≈1.3s). The hybrid async pipeline removes the hot-account bottleneck while preserving double-entry correctness.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:28What is double-entry accounting
- 3:55Why track money with a ledger
- 5:39Basic ledger data model
- 7:43Performance bottleneck in ledgers
- 10:53Solving balance consistency with versions
- 12:19API usage example
- 14:49Performance test setup
- 17:17Hot account problem
- 20:27Asynchronous batch processing
- 22:31Hybrid synchronous async workflow
- 25:02Handling queue failures
- 28:35Out-of-order message handling
- 32:08Monitoring queue latency
- 35:20Verifying account balances
- 37:08Design advice for ledgers
- 38:11Q&A session
