Write throughput in Ledger 3.0 is governed by the consensus and apply path described in How Ledger Stores and Replicates Data, not by database contention. That changes which modeling decisions matter.
This page covers the decisions you make in your application. For node sizing and server tuning, see Plan Capacity and Tune Performance.
Three techniques from Ledger 2.x no longer apply
- Spreading writes across synthetic source accounts. Hot accounts no longer queue on a row lock. Fanning
@worldout into@world:<random>now costs account cardinality and buys nothing. - Disabling or deferring log hashing. The audit chain covers every proposal and is not a throughput setting.
- Adding named ledgers to buy write parallelism. All ledgers in a cluster share one Raft group and therefore one ordering domain. More ledgers is a modeling decision, not a scaling one.
What a write costs#
A write moves through three stages. Knowing which stage your design loads is how you decide what to change.
| Stage | Where it runs | What drives the cost |
|---|---|---|
| Admission | Leader only | Parsing Numscript, resolving the accounts the script touches, loading any account whose balance must be checked |
| Consensus | Every voter | One Raft entry per proposal, replicated and appended to the WAL; Raft batches entries and syncs the WAL once per batch |
| Apply | Every node | Deterministic state machine execution; the applier commits one storage batch for several entries |
Raft and the applier already amortize syncs and storage commits across entries, but every proposal still costs its own Raft entry, replication, and state machine execution, and that cost is per proposal, not per transaction. That fact drives most of the guidance below: anything that puts more useful work into one proposal, or less work into admission, raises throughput.
Reuse script text, vary the values#
Ledger caches parsed Numscript by the hash of the program text. Identical text is a cache hit; every distinct text pays a full parse on the leader.
Write one parameterized program and vary the arguments:
Generating a fresh program per transaction with the accounts and amounts inlined defeats the cache entirely, and the parse cost then grows linearly with traffic. Parameterize everything that varies, including addresses with a dynamic segment: build the full address in your application and pass it as an account variable.
Pass escrow:order-00001 as $escrow, and the program text stays identical for every order.
The cache is bounded. Most applications need a handful of programs; if yours holds more distinct program texts than the cache can keep, older entries are evicted and re-parsed. Watch numscript.cache.size and see Monitor Ledger.
Design addresses for the storage layout#
Account addresses are part of every storage key, so their shape has a measurable cost. This reinforces the conventions in Design a Chart of Accounts rather than competing with them.
- Keep the leading segments stable and put the varying part last. The store is an LSM tree: keys sharing a prefix compact better, and the range scans behind account listing stay tight.
escrow:order-00001is a better shape than a bare random identifier. - Prefer time-ordered identifiers. If addresses embed a UUID, UUIDv7 preserves temporal locality where UUIDv4 destroys it.
- Keep segments short. Every byte is carried in storage keys, replicated protobuf messages, and script execution context. In-memory cache keys are fixed-size hashes, so they do not grow with the address.
usr:alice:chkandusers:alice:checkingare equally readable in context; one is materially cheaper at volume. - Keep the account count per script low. Every distinct account in a program adds resolution work at admission. Use multi-source and multi-destination patterns when the business logic calls for them, not by default.
Batch, and know which cost each mode removes#
Batching removes two different costs, and the REST bulk route removes them only when you ask it to.
| Network round trips | Raft entries | |
|---|---|---|
| 50 individual requests | 50 | 50 |
| REST bulk, sequential (the default) | 1 | 50 — each element is proposed on its own |
REST bulk with atomic=true | 1 | 1 — the batch is proposed as one command |
gRPC Apply with 50 actions | 1 | 1 |
Sequential bulk is still worth using — it collapses the round trips — but it does not amortize consensus. If you are batching to reduce Raft load rather than network chatter, the batch has to be atomic.
So pick the mode from the commit boundary you actually need, and read the throughput consequence off the table rather than assuming the batch buys it:
| Mode | Behavior | Use when |
|---|---|---|
atomic=true | One business failure rolls back the whole batch | The batch is one logical operation, or you need the consensus saving |
| Sequential (default) | Each element succeeds or fails independently | Partial success is acceptable and the round-trip saving is enough |
Start around 50 elements per request and tune from there: larger batches raise throughput but also raise per-request latency, memory, and the blast radius of a retry.
The REST bulk route is scoped to one ledger, so atomic=true there means atomic within that ledger. Cross-ledger atomic batches require the gRPC Apply surface. See Write Transactions in Bulk.
Skip balance checks you do not need#
An account whose balance must be validated has to be resolved before the proposal is made. An account declared as allowing unbounded overdraft does not.
Use this for sources that are funded by construction — @world, or a treasury account whose balance your application already governs. Do not use it to silence a check you actually rely on: it removes the guarantee, not just the cost.
Scale reads with followers#
Reads are served locally by any node, leader or follower, so read capacity grows by adding nodes. By default a read establishes a consensus barrier before serving, which is what makes it linearizable. A read that explicitly opts into stale consistency skips the barrier and may lag the leader.
Decide per read path which of those you need; see Read Consistency and Checkpoints.
What to do when one cluster is not enough#
Because a cluster is one ordering domain, the way past its write ceiling is another cluster, not more ledgers inside it. Treat that as a deliberate topology decision with its own routing and reconciliation design, not as a tuning step.
Before concluding you need it, establish a measured baseline on representative traffic. Plan Capacity and Tune Performance describes how to build one and why a transactions-per-second figure without workload context is not a capacity commitment.
Review#
Before connecting production traffic, confirm that:
- the application sends a small, fixed set of Numscript programs and varies them with variables;
- account addresses share stable prefixes and avoid random leading segments;
- writes are batched, with the mode chosen against the commit boundary you need and the batch size against measured latency;
- unbounded overdraft is declared only where the balance check is genuinely unnecessary;
- read paths state whether they require a linearizable read or tolerate a stale one;
- the capacity baseline was measured on your own workload, not inherited from a published number.