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.
[!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 ROWhome), 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.
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).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.
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 countersGLOBALoptimizes reads by making writes globally coordinated and slower. The oversell-criticalinventory.availablecounter is write-heavy and contended, which is the workloadGLOBALpenalizes. KeepinventoryREGIONAL BY ROW(orREGIONAL BY TABLEwhere 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.
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.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 UPDATEserializes writers on a hot SKU cleanly (SELECT FOR UPDATE).- Counter sharding splits
inventory.availableinto N sub-rows summed on read, spreading the write hotspot across ranges. - Tiny, single-batch transactions minimize the contention window.
READ COMMITTEDwith guards reduces retries where theWHEREguard andFOR UPDATEmake it safe; keep the guards, becauseREAD COMMITTEDpermits lost updates without them.- Offload availability-display reads to follower reads, keeping the leaseholder free for decrements.
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.
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, orREGIONAL BY TABLEwhere an entire table belongs to one region. - Keep only non-regulated, read-mostly reference data (for example, a product catalog)
GLOBAL. Rows in aGLOBALtable are replicated to every region, so do not place regulated records there.
[!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.

