Image 1 of 2: Grafana service health dashboard with request rates, error rates, latency quantiles and circuit breaker states
Moves money only between wallets inside the system, so a transfer on one shard is one serializable Postgres transaction, and cross-shard transfers go through a two-phase clearing-account saga. Go services publish through a transactional outbox to Kafka, behind Envoy, with webhooks, a DLQ and replay.
- 3,000+ RPSBurst (live K8s)
- <40 msP50 at burst
Trade-offs
- Closed loop: money only moves between wallets inside the system. Same-shard transfers need no saga or distributed lock, and only cross-shard ones pay for a two-phase clearing-account saga.
- Ledger history is append-only, so mistakes are fixed by correction postings, never by editing entries.
- Webhooks are ordered per merchant by partitioning the Kafka topic on
merchant_id, which orders delivery per merchant but not across them.
Q&A4
A
UNIQUE(merchant_id, idempotency_key) constraint on jobs gives at-most-once execution, alongside the other written invariants.The balance row is read
FOR UPDATE and checked before the debit, inside the serialized wallet transaction.Each transfer is an atomic double-entry transaction with
UNIQUE(transfer_id, leg), so a leg can't be written twice or alone.It lands in a transactional
dlq_entries table, from which an admin API can replay it. Jobs have bounded timeouts and token-bucket retry budgets, so none retries forever.Links
- GitHub(opens in a new tab)github.com/Joel-Ajayi/river-rust-queue
- Invariants(opens in a new tab)github.com/Joel-Ajayi/river-rust-queue/blob/5cf91bc9d545ca2c90d7db90a1a1692354b02472/docs/INVARIANTS.md
- Architecture(opens in a new tab)github.com/Joel-Ajayi/river-rust-queue/blob/5cf91bc9d545ca2c90d7db90a1a1692354b02472/docs/ARCHITECTURE.md
- Load tests(opens in a new tab)github.com/Joel-Ajayi/rrq-gitops/tree/main/tools/load-tests
Built by
Reviews
Loading reviews
More in Payments
See all 9 →
OffPayOffline UPI payments over *99# USSD, with no data connection
go-ledgerMulti-tenant double-entry payment ledger API in Go, built in public
SellfSelf-hosted storefront for digital products on the seller's own Stripe account
PandaPayLensPayment error decoder and event timeline that runs in the browser
PartageEnd-to-end encrypted, local-first bill splitting with no accounts
minshopSmall store on Cloudflare Workers that agents can pay
More in Ledgers
See all 7 →- pgledgerDouble-entry ledger implemented entirely in PostgreSQL functions and views
HisabDouble-entry ledger kept by texting a WhatsApp agent, in Urdu or English
Accountant24Personal finance agent that keeps an hledger ledger in plain text under git
OpenBilanzLocal tool for a German GmbH's opening balance, annual accounts and E-Bilanz- franken_accountingEvidence-native double-entry accounting system of record in Rust
More in Distributed systems
See all 20 →
arbiterPostgreSQL job queue for Haskell, with no broker and no leader
RuvioRust key-value server that speaks RESP, with locks and queues as commands
EgresPostgres-compatible database in Zig for heavy, multi-tenant workloads- clinkC++ stream processing engine that stays correct when processes die
- pg-statusSidecar that reports PostgreSQL master, replicas and replication lag
LassoSelf-hosted Ethereum JSON-RPC proxy that routes each call to the best provider