Skip to main content
This page extends the single-region order system to run close to users in multiple geographies, survive the loss of an entire region, and absorb flash-sale traffic. Each rule below states the recommendation, the reason it holds, the DDL/SQL, and both sides of the tradeoff. The entities are the same throughout: orders, order_lines, inventory, reservations.

Get single-region correctness first: multi-region is an extension

Rule. Do not reach for multi-region until your single-region system is correct. Why. Multi-region changes where data lives and how far a quorum must travel. It does not change the correctness primitives: the guarded decrement, idempotent order creation, and guarded state transitions (Transactions & SQL), and the counter/ledger inventory model (Schema design). If overselling is possible in one region, spreading the data across three regions makes it more likely, not less, because latency widens the window for contention. Multi-region is a deployment property layered on a correct schema, not a substitute for one. When it is required. Three drivers, and only these:
  • Latency near users. Home each customer’s rows in the region they read and write from.
  • Data residency. Keep EU customer rows physically in the EU, US rows in the US.
  • Region-failure survival. Continue accepting orders when an entire cloud region becomes unavailable.
If none of these apply, stay single-region. See the Multi-region overview.
[!NOTE] Enterprise licensing: NEEDS VERIFICATION Multi-region SQL (table localities, survival goals) and bounded-staleness follower reads are gated behind the CockroachDB Enterprise license under the current CockroachDB Software License. Confirm your entitlement before designing around these features: Licensing FAQs.

”Multi-region” is not automatically “active-active”

Two or three regions in a cluster do not mean every region accepts every write at local latency. Before describing a design as active-active, specify three things:
  • Write ownership: which region owns each row’s writes (its REGIONAL BY ROW home), so that the normal write path is local rather than paying cross-region consensus on every transaction.
  • Read behavior: which reads must be fresh (leaseholder) and which tolerate staleness (follower reads).
  • Failover: what happens on a region loss, and whether the latency and consistency behavior has been validated rather than assumed.
A design in which one region owns a row’s writes and other regions read it is a sound architecture; describe it precisely. Where the consistency boundary allows, batch writes to reduce per-operation cross-region overhead.

Choose a table locality per access pattern

Rule. Pick the locality that matches each table’s read/write geography. The three localities are REGIONAL BY TABLE, REGIONAL BY ROW, and GLOBAL. First declare the database’s regions:

REGIONAL BY TABLE: one home region for the whole table

Fast reads and writes in a single region; other regions pay cross-region latency. Use it when a table is owned by one region (for example, a region-local operations table).
Tradeoff. Lowest latency for the home region and highest for all others. Unsuitable for data whose users are spread across regions.

REGIONAL BY ROW: per-row home via crdb_region

Each row carries a hidden crdb_region column that determines where it lives. Home each order and customer near the user who owns it. This is the primary locality for order data.
Tradeoff. Local-speed reads and writes for rows homed in the caller’s region; cross-region access to a row homed elsewhere still pays the WAN cost. It also satisfies data residency: EU rows with crdb_region = 'europe-west1' remain in the EU.

GLOBAL: low-latency reads everywhere, slower writes

Every region reads locally at the cost of higher write latency. Suited to read-mostly reference data: product catalog, tax tables, currency reference.
[!CAUTION] GLOBAL is wrong for inventory counters GLOBAL optimizes reads by making writes globally coordinated and slower. The oversell-critical inventory.available counter is write-heavy and contended, which is the workload GLOBAL penalizes. Keep inventory REGIONAL BY ROW (or REGIONAL BY TABLE where stock is region-local) so that the decrement remains a fast, local leaseholder write.

Pick a survival goal deliberately

Rule. Set survival to ZONE or REGION based on what failure you must survive, not by default.
  • ZONE (default). Survives losing nodes/zones within a region. Lower write latency because quorum can stay inside one region.
  • REGION. Survives the loss of an entire region. Requires at least 3 regions, and costs write latency because every write quorum must span regions.
Tradeoff. SURVIVE REGION FAILURE provides continuous order-taking through a region outage, but every write then waits on a quorum acknowledgment from a remote region. The added commit latency is unavoidable: it is the physical cost of durability across regions. Choose REGION only when a region outage is a business-critical event that must be survived; otherwise ZONE keeps writes fast.

Scale reads with follower reads: never the oversell decrement

Rule. Serve high-volume, staleness-tolerant reads from the nearest replica with follower reads. Order history and availability display qualify. The inventory decrement does not.
Follower reads scale reads horizontally: any replica can serve them, so they do not accumulate on the leaseholder. Bounded staleness (with_max_staleness() / with_min_timestamp()) is restricted to single-statement, single-row, read-only queries with no index join.
[!CAUTION] Never serve the oversell decrement from a stale read The UPDATE inventory SET available = available - $qty WHERE available >= $qty must execute against the fresh leaseholder write path. A follower read is stale by design (roughly 4.2s or more for exact staleness). Deciding “in stock” from stale data and then writing reintroduces the exact race the guarded decrement exists to prevent, and will cause overselling. Follower reads are read-only and for display only. The decrement is a fresh leaseholder write.

Flash sales & hot SKUs at scale

Rule. Combine every single-region mitigation, then offload display reads to followers and size the cluster for the spike.
  • Guarded decrement rejects oversell at 0 rows affected (Transactions & SQL).
  • SELECT ... FOR UPDATE serializes writers on a hot SKU cleanly (SELECT FOR UPDATE).
  • Counter sharding splits inventory.available into N sub-rows summed on read, spreading the write hotspot across ranges.
  • Tiny, single-batch transactions minimize the contention window.
  • READ COMMITTED with guards reduces retries where the WHERE guard and FOR UPDATE make it safe; keep the guards, because READ COMMITTED permits lost updates without them.
  • Offload availability-display reads to follower reads, keeping the leaseholder free for decrements.
Capacity. Hot rows and ranges are addressed by load-based splitting and by adding nodes to scale throughput; see Performance best practices. Load-test at roughly 2x expected peak so that headroom is proven before the sale rather than discovered during it. Tradeoff. Sharding and FOR UPDATE add code and read-time aggregation; the benefit is surviving a SKU that would otherwise serialize the entire sale onto one hot range.

Data residency and compliance

Some order data is subject to data-residency or data-sovereignty requirements. A regulation may require that a customer’s personal data, or an order’s records, be stored and processed within a specific country or region. Responding to this by running a separate database per jurisdiction creates data silos, duplicates operational work, and removes any single view of inventory and orders. CockroachDB enforces residency within one multi-region cluster. REGIONAL BY ROW assigns each row a home region through the hidden crdb_region column, so an order or customer record is stored and served from the region its residency rules require while the cluster remains a single logical database.
Determine each row’s home region from the data itself rather than from where the write originates. Set crdb_region explicitly on insert, or derive it from an application column such as the order’s jurisdiction, so that a record governed by a given regulation is always homed in the corresponding region. Apply localities according to residency scope:
  • Keep jurisdiction-bound tables REGIONAL BY ROW, or REGIONAL BY TABLE where an entire table belongs to one region.
  • Keep only non-regulated, read-mostly reference data (for example, a product catalog) GLOBAL. Rows in a GLOBAL table are replicated to every region, so do not place regulated records there.
For stricter isolation (for example, confining a set of regions’ data to a defined subset of nodes), review super regions and data placement controls.
[!NOTE] Verify residency guarantees Data residency and sovereignty are legal obligations. Confirm the specific regulation’s requirements, the regions the cluster spans, and the current CockroachDB multi-region, placement, and licensing behavior before relying on this configuration for compliance.
The same mechanism, binding each record’s storage to a required region within one cluster, supports any workload that must keep a jurisdiction’s data in that jurisdiction.

Observability & disaster recovery

Rule. Monitor CDC health and contention continuously; treat multi-region survival and backups as complementary layers of disaster recovery (DR).
Monitor changefeed job status for the outbox/CDC pipeline (Change data capture overview) alongside standard contention and hot-range metrics. DR has two layers. Multi-region survival goals provide in-cluster high availability: the cluster keeps serving through a region loss. Backups and point-in-time recovery (PITR) are a separate, complementary layer protecting against logical corruption and operator error. Survival does not replace backups, and backups do not provide zero-downtime failover. Backup and PITR specifics are out of scope here; see Change data capture overview and the multi-region documentation for the survival side.

Tradeoffs summary