Consider a CockroachDB stretch cluster across two clouds… Anyone designing a cluster like this soon faces one question:
"What is the real difference between RF 3 and RF 5, and why does it matter when a node fails?"
This post answers that with animations, one step at a time.
1. The setup and four terms you need
- Azure Canada Central (primary): Node 1 and Node 2. The Azure application connects here.
- Azure Canada East (vote only): Node 4. A tie-breaker location with no application traffic.
- AWS ca-central-1 (secondary): Node 3 and Node 5. The AWS application connects here, and this region takes over if Azure Central fails.
- Network round trips over the private VPN: about 10 ms from Central to AWS or East, about 20 ms from AWS to East, and about 1 ms inside a region.
| Term | Simple meaning |
|---|---|
| Replica (copy) | CockroachDB splits data into ranges. Each range is stored as several full copies on different nodes. |
| RF (replication factor) | How many copies of each range exist. |
| Voter and quorum | Voters are the copies that vote on every write. A write is saved only when more than half of the voters agree. That majority is the quorum. |
| Leaseholder | The one copy of a range that answers reads and coordinates writes. All other copies stay up to date and vote. |
Easy rule: quorum = (voters ÷ 2, rounded down) + 1. With 3 voters you need 2. With 5 voters you need 3. The number of copies you can lose is voters − quorum.
2. RF 3: how a write commits
With RF 3 there is one copy in each region. The leaseholder sits in Azure Central, close to the application.
- The Azure app sends a write to the leaseholder (Node 1).
- The leaseholder writes its own copy. That is vote 1.
- It sends the write to the copies in Canada East and AWS at the same time.
- The first answer back is vote 2. That is 2 of 3, a quorum, so the write is committed in about 10 ms.
The 10 ms is the price of safety. Every committed write already exists in two regions.
3. The RF 3 problem: one node fails
Now Node 1 fails. With RF 3, Azure Central has only one copy of each range: some ranges have it on Node 1, others on Node 2. For every range whose copy was on Node 1:
- Problem 1: reads slow down. Node 2 has no copy of that range, so the leaseholder role jumps to AWS. Every read from the Azure app now crosses the VPN, at about 10 ms per read instead of about 1 ms. A business transaction that runs dozens of statements feels this straight away.
- Problem 2: no spare copy. Only 2 of 3 copies are left, which is exactly the quorum. One more failure and that range stops accepting writes.
- After a few minutes, CockroachDB builds a new copy on Node 2 and the leaseholder returns to Azure. Until then, the application runs slower and with no safety margin.
4. RF 5: how a write commits
With RF 5 there are 5 copies, placed by CockroachDB's voter constraints: 2 in Azure Central, 2 in AWS and 1 in Canada East.
- The leaseholder writes its own copy: vote 1.
- Node 2, in the same region, answers in about 1 ms: vote 2.
- The nearest other region answers in about 10 ms: vote 3. That is 3 of 5, so the write is committed in about 10 ms.
Write speed is the same as RF 3. The quorum still needs one vote from outside Azure Central, which is what guarantees no data loss if the region is lost.
5. RF 5: the same node failure, with no slowdown
- Node 1 fails, but Node 2 already has a full copy of every range.
- The leaseholder moves to Node 2 and stays in Azure Central, so reads stay at about 1 ms.
- 4 of 5 copies are left and the quorum is 3, so one more node can still fail.
6. RF 5: the whole Azure Central region fails
- Both Azure Central nodes go down.
- The AWS copies already hold all the data, because they voted on every write. No data is copied. Only the leaseholder role moves to AWS, the secondary region.
- 3 voters remain (2 in AWS and 1 in Canada East). That is 3 of 5, still a quorum, so writes keep committing at about 20 ms, because the third vote now comes from Canada East.
- Result: no data loss and no manual failover. The AWS application keeps working.
7. Summary
| RF 3 | RF 5 | |
|---|---|---|
| Copies of each range | 3 (one per region) | 5 (2 Central, 2 AWS, 1 East) |
| Write needs | 2 of 3 | 3 of 5 |
| Time per write | ~10 ms | ~10 ms |
| Survives | 1 node or 1 region | 2 nodes or 1 region |
| One primary-region node fails | Some leaseholders move to AWS, reads ~10 ms | Stays in Azure, no slowdown |
| Spare copies after one node fails | None | One |
| Storage | 1× | ~1.67× |
8. How to set it up
You do not need to set RF 5 or the voter constraints by hand. CockroachDB's multi-region SQL configures them for you:
ALTER DATABASE mydb SET PRIMARY REGION "canadacentral"; ALTER DATABASE mydb ADD REGION "cacentral"; ALTER DATABASE mydb ADD REGION "canadaeast"; ALTER DATABASE mydb SURVIVE REGION FAILURE; -- sets 5 voters, 2 in the primary region ALTER DATABASE mydb SET SECONDARY REGION "cacentral"; -- 2 voters in AWS, the failover target
Check the result with:
SHOW REGIONS FROM DATABASE mydb; SHOW SURVIVAL GOAL FROM DATABASE mydb; SHOW ZONE CONFIGURATION FROM DATABASE mydb;
9. Practical lessons
- RF 5 does not make writes slower than RF 3 in this layout. Both need one vote from another region.
- RF 5 keeps reads local when a node fails, because the second node in the primary region already has a copy. With RF 3, the leaseholder jumps to the other cloud.
- A failover to the secondary region is automatic. Only the leaseholder role moves, not the data.
- Plan the conversion window. On a database with a very large number of tables, the multi-region commands can take hours, so run them outside business hours.
- Keep the tie-breaker region free of application traffic. Its job is only to vote.
If you are designing a multi-cloud database, start with the question: "What happens to my reads when one node in my primary region fails?" The answer usually decides between RF 3 and RF 5.






