Skip to the page

Ship and scale

Chapter 10 of 11

Scale and the chaos lab

Branches, read replicas and root-placed shards scale your project behind one hostname. Isolated branches test migrations before deploy, and public fault campaigns verify failover and durability on every release.

Running everything on one primary database works early on, then hits three production walls: testing risky migrations safely, scaling throughput and storage past a single machine, and surviving hardware failures without losing acknowledged writes.

Try it

Create an isolated database branch and test a schema migration without touching main.

Your terminal
napalm branches create notes pr-12
Created pr-12 in notes from main with no rows.
napalm schema push notes --branch pr-12 --yes
ALTER TYPE default::Note {
CREATE PROPERTY archived: std::bool;
};
Migrated pr-12 in notes: 1 change
The migration applies to pr-12 alone while production traffic continues on main.

Branches#

Pillar at work: Compiled

Each branch is an independent database beside main with separate rows, service keys and session keys. Developers iterate on personal branches, pull-request CI creates ephemeral branches such as pr-12 to validate migrations and saved queries, and teams can run release rehearsals on branches cloned from main’s live data.

Isolated branches

Each branch keeps separate rows, service keys and sessions beside production.

Checked migrations

Every branch push validates your saved queries before applying DDL.

Because every push validates your query folder against the target branch schema first, incompatible changes fail in development or CI before reaching main.

Horizontal shards#

Pillar at work: Distributed from links

When write throughput or storage outgrows a single primary, napalm placement enable activates horizontal sharding across multiple PostgreSQL primary-replica shards without changing your schema, uuid primary keys or client queries.

Using the placement roots inferred from required single links or declared with ext::napalm::root, Napalm places each root record and all of its rooted descendants on one shard while replicating 'reference' lookup tables to every shard in one commit. Whether your schema’s root type is Account, Project, Site or Organization, single-root reads and writes execute locally on the owning shard with zero cross-shard fan-out.

Terminal
napalm placement enable notesnapalm placement split notes --shard shard-0a1b2c3d4enapalm placement keep notes <root-id> --region iadnapalm placement restore-root notes <root-id> --to 2026-11-10T17:20:00Z
Enable root placement, split a busy shard, pin a root to a region or rewind one root to an earlier timestamp.

Splitting a shard or moving a high-traffic root happens behind the same project hostname. Reads stay live throughout the move while writes to the moving root pause briefly at cutover, and napalm placement restore-root rewinds a single root subtree without rolling back the rest of the cluster. The branch-wide change log runs on single-shard branches.

Root-placed shards

Each root record and its descendants stay on one shard and move online.

Engines and replicas#

Pillar at work: Commit-atomic

Stateless engines compile EdgeQL and route requests in front of your shards, while each replicated shard runs a primary and cross-zone read replicas. On clusters with a replica, writes confirm on both the primary and an in-region replica before returning. If no replica responds for 5 seconds, the primary commits alone until a replica returns.

Terminal
napalm clusters scale <cluster> --engines 4 --replicas 2
Scale stateless engines and cross-zone read replicas online.

Generated SDKs forward the Napalm-Bookmark header automatically so read queries route only to replicas caught up to the caller’s own commits. If a primary stops answering for 30 seconds, a replica promotes automatically behind the same project address.

Stateless engines

Scale query compilation and live connections without moving stored data.

Causal read replicas

Bookmarks keep reads fresh while cross-zone replicas stand ready for failover.

Fault campaigns and promises#

Every Napalm release runs an automated fault campaign before rollout, and nightly campaigns test the live release again. Results publish to the chaos lab.

Public fault campaigns

Release and nightly runs test real faults and publish every verdict.

Scenarios are grouped by the system guarantee under test.

GroupPromise verified
WritesPromise verifiedAcknowledged writes survive server crashes, freezes and full disks.
ReplicasPromise verifiedA replica takes over when a primary fails. Two primaries never write at once.
Change log and webhooksPromise verifiedAcknowledged writes reach the change log and signed webhooks in commit order.
PresencePromise verifiedRoom members keep their places when a server crashes.
ShardsPromise verifiedA cross-shard write commits on both shards or on neither shard.
AccessPromise verifiedRevoked credentials read zero rows even on a lagging replica. Tenants never see another tenant’s rows.
LoadPromise verifiedExpensive read queries never starve concurrent writes.

Inside a run and public verdicts#

Pillar at work: Checked and fault-tested

Each scenario provisions fresh clusters running the release under test while clients drive continuous reads and writes and record every acknowledged commit. Mid-run, the harness injects a bounded fault such as a database server crash, a frozen server, a severed cross-zone network link or a full disk, then verifies every acknowledged write and access policy afterward.

Published run · Broken canopy
Scenario    Broken canopy · 2026.11.6Fault       A replica drops off the network for 10 seconds while clients write.Verdict     Passed Promises  ✓ The primary keeps taking writes.  ✓ The cut-off replica refuses a write.  ✓ The replica catches up once the network returns. Evidence  Acknowledged writes          1,420 writes  Writes lost or changed       0 writes  Stale reads                  0 reads  95th percentile write time   0.04 s
Published runs pair each scenario’s required outcomes with the post-fault measurements.

Every run ends in one of three verdicts. Passed confirms that the fault took effect and every durability, latency and access invariant held. Failed means at least one invariant broke. Inconclusive means incomplete evidence prevented verification and never counts as a pass.

Failed and inconclusive runs remain on the public record beside passes. Access scenarios combine network partitions and server crashes with credential revocation to verify that even a partitioned replica refuses reads from a revoked grant.

Across branches, replicas, shards and injected faults, one compiled schema holds every guarantee together.

Type a word or two to search every docs page.