Preview. Stack v4.0 has not been released, and what is documented here can still change before it does. The current release is v3.2, which covers this as Ledger.Go to v3.2
Ledger

How Ledger Stores and Replicates Data

Why Ledger 3.0 owns its storage and ordering instead of delegating them to PostgreSQL.

Ledger 3.0 stores its data in an embedded Pebble store on each node and replicates every write through Raft consensus. There is no PostgreSQL server in the deployment.

This page explains why that changed, because the reasoning determines how you design for throughput and what you are responsible for operationally.

What PostgreSQL was actually doing#

Ledger 2.x kept its state in PostgreSQL, but the database was never only a place to put rows. It was the concurrency engine. Two database mechanisms enforced correctness:

MechanismWhat it protectedWhat it cost
Row-level locks on the balance tableTwo transactions could not update the same account's volumes at onceConcurrent writes to one account queued behind each other
A per-ledger advisory lock on log insertThe hash-chained log stayed strictly ordered and gap-freeWrites within one ledger were serialized

Both are correct. Both are also throughput ceilings, and they are the reason the 2.x guidance reads the way it does: spread writes across many source accounts so they hit different rows, and split across many named ledgers so they take different advisory locks.

The second ceiling had a worse consequence. Because the advisory lock was taken to maintain the hash chain, the documented way to lift it was to stop maintaining the chain — turning log hashing off or making it asynchronous. Integrity became a throughput setting you could trade away.

Where ordering comes from in 3.0#

Ledger 3.0 takes ordering back from the database and does it itself.

  1. The leader validates and prepares a proposal, resolving any state it needs first.
  2. Raft orders and replicates that proposal across the cluster.
  3. A deterministic state machine applies the accepted proposal identically on every node.
  4. State lands in the node's local Pebble store as part of that controlled apply path.

A follower that receives a write forwards it to the current leader. All ledgers in a cluster share one Raft group, so every accepted mutation takes a place in a single ordering domain.

What that changes#

ConcernLedger 2.xLedger 3.0
Write orderingPostgreSQL row and advisory locksRaft consensus over one global ordering domain
Concurrent writes to one accountQueued behind a row lockOne current volume pair per account, color, and asset, overwritten (last-write-wins) as the state machine applies entries in Raft order; that ordering serializes updates, so there are no row locks
IntegrityHash chaining, which could be turned off for throughputAudit hash chain over every proposal, always maintained
Current balanceRows updated under database concurrency controlA persisted projection the state machine maintains deterministically
Failover and replicationOwned by the PostgreSQL deploymentLeader election, quorum, WAL, and snapshots owned by Ledger
DeploymentApplication plus an external databaseSelf-contained ledger nodes

Two consequences of Raft ordering and the deterministic state machine that invert previous advice that was correct in Ledger 2.x:

  • Hot accounts are no longer a bottleneck. A central wallet, treasury, or fee collector debited by heavy concurrent traffic no longer queues. Splitting one logical account across many synthetic addresses to spread row-lock pressure is no longer a throughput technique. You can design your chart of accounts according to business requirements!
  • Integrity is not a throughput lever. The audit chain covers every proposal and is no longer something you turn off to go faster. The hash primitive is a cluster-wide choice: blake3, the default, is cryptographic and makes the chain tamper-evident; xxh3 is faster but non-cryptographic, so it detects corruption only. Choosing xxh3 trades tamper evidence for speed; it does not switch the chain off.

What you still own#

Removing the database does not remove persistence engineering. It moves it inside the ledger's operational boundary, where it remains your responsibility:

  • Quorum topology. Three voters is the normal production starting point. See Manage the Cluster Lifecycle.
  • WAL placement. Raft WAL writes are synchronous and on the critical path of every write. They belong on fast storage, separated from data I/O where the platform supports it.
  • Storage growth. History is permanent — there is no retention or archival tier. See Plan Capacity and Tune Performance.
  • Backup and restore. Application-level checkpoints and snapshots, not a database backup. See Back Up Ledger.

Ledger 3.0 is not a drop-in replacement for a 2.x deployment. If you are moving an existing ledger, start with the migration overview, which covers mirroring from a running 2.x instance and cutting over.

Next#