All posts
Fintech
3 min read• 12/6/2026

Why Postgres Double-Entry Fails at 10k TPS (And What to Build)

Relational row-locking kills throughput in modern core banking systems. High-scale multi-currency financial ledgers require deterministic state machines and unbundled storage architectures.

Share X LinkedIn

Tip: use ← / → to browse posts.

Why Postgres Double-Entry Fails at 10k TPS (And What to Build)
## The Illusion of the ACID Relational Ledger Every fintech starts the same way. You need a ledger, so you spin up PostgreSQL. You create an `accounts` table and an immutable `journal_entries` table. To execute a transfer, you wrap the debit, credit, and balance validation in a SQL transaction with `SELECT ... FOR UPDATE`. It works cleanly up to 500 transactions per second (TPS). Then your payments pipeline scales, or you onboard an enterprise merchant doing batch disbursements. Suddenly, transactions grind to a halt. Deadlocks spike. P99 latency shoots into seconds. Database CPU saturates at 100%—not because the hardware is weak, but because relational row-level locks force sequential execution over shared accounts. If you intend to process high-throughput payments, real-time micro-settlements, or modern neo-banking corridors, traditional relational databases are the wrong tool for the ledger foundation. ## The Physics of Contention In standard double-entry systems, transactions do not distribute evenly across the account tree. You inevitably have hotspot accounts: omnibus clearing accounts, platform fee accounts, and treasury settlement pools. When 5,000 parallel workers try to credit your platform revenue account simultaneously: 1. PostgreSQL places an exclusive row-level lock on that single account row. 2. Transactions line up in memory, waiting on lock acquisition. 3. Write-Ahead Logs (WAL) experience massive contention as engine locks block the execution pipeline. 4. Latency ripples outward to client-facing APIs, causing client timeouts and toxic retry storms. Partitioning, sharding, and Read Replicas cannot resolve this because the bottleneck is fundamentally write contention on mutable account balances. ## Architectural Alternative: Deterministic Batching & Fixed-Schema Ledgers To break past the 10,000 TPS ceiling without sacrificing the sacred rule of zero balance drift, you must abandon ad-hoc SQL semantics in favor of a specialized, deterministic ledger engine such as TigerBeetle or an internal deterministic state machine running over Raft. ### The Three Primitives of Scale * **Unbundled Storage**: Account balances are not updated in place via mutable updates. Balances are derived through strict deterministic batch aggregation. * **Batch-First Consensus**: Instead of processing single transfers, the engine clusters incoming transactions into fixed ring buffers (e.g., 8,192 entries per batch) and checks constraints across the entire batch in a single cache-coherent sweep. * **Memory-Mapped Architecture**: Zero allocations on the hot path. Static memory footprints prevent garbage collection spikes and CPU context switching. ```zig // Conceptual TigerBeetle style account transfer structure const Transfer = extern struct { id: u128, debit_account_id: u128, credit_account_id: u128, amount: u128, pending_id: u128 = 0, user_data_128: u128 = 0, user_data_64: u64 = 0, user_data_32: u32 = 0, timeout: u32 = 0, ledger: u32, code: u16, flags: u16, timestamp: u64 = 0, }; ``` By representing transfers as packed, fixed-size byte structures, the engine operates on thousands of operations per second directly inside CPU L1/L2 caches, bypassing relational query parsing, AST generation, and connection pooling bottlenecks. ## Two-Phase Transfers for Real-World Clearing Financial operations rarely settle instantly. They pend, await card network clearing, or require fraud screening. Traditional systems handle this by adding complex string statuses (`pending`, `cleared`, `reversed`) to a database column, making invariants impossible to enforce purely through foreign keys. A dedicated financial state engine handles this through native two-phase transfer primitives: 1. **Pending Stage**: The engine reserves the requested amount on `debit_account_id` without incrementing the cleared balance of `credit_account_id`. The user's available funds decrease, preventing double-spending. 2. **Settlement Stage**: A secondary message provides the `pending_id`, immediately moving funds to cleared balances. 3. **Expiry Stage**: If the pending transaction exceeds its `timeout`, the reservation is automatically rolled back by the engine without external cron jobs. ## Where Postgres Still Belongs This is not an argument to dump PostgreSQL completely. Postgres is phenomenal at querying auxiliary customer information, KYC documents, rich billing metadata, and compliance reporting. The clean architecture separates **Ledgering** from **Querying**: * **Core Ledger Engine (TigerBeetle / Event-Sourced Kernel)**: Manages account balances, invariant validation, and zero-drift transfers at 50,000+ TPS. * **Message Pipe (Kafka / Redpanda)**: Streams committed, immutable financial events out of the engine ring buffer. * **Postgres / ClickHouse (Read Store)**: Consumes the events, hydrates user dashboard views, and powers analytical reporting queries. Keep your balances out of mutable relational tables. Treat financial accounting as a high-speed, deterministic state problem—your infrastructure, and your sleep schedule, will thank you.
fintech
distributed-systems
tigerbeetle
databases
architecture
Share X LinkedIn

What clients say

Real reviews from founders and teams we've shipped with.

5.0 · 6 reviews
"The trading store is fast, secure, and converts. Hashim genuinely understands fintech."
Daniel O.
CEO, FX TradeStore
"Vercel + Neon + Drizzle stack shipped in days. The architecture doc alone was worth it."
Sofia L.
Founder, Draftbase
"Our Next → TanStack migration cut TTFB in half. Hashim's diagnosis was surgical."
Lena K.
Staff Engineer, Northloop
"Framer Motion animations that actually respect prefers-reduced-motion. Details matter, and Hashim gets it."
Owen S.
Design Lead, Studio Kai
"Real-time data, clean charts, zero downtime. Exactly what a trading platform should be."
Chen H.
CTO, Gold Online Trade
"Postgres schema and indexes were rebuilt properly. Queries that took seconds now take milliseconds."
Hana Y.
DBA, Datacore