This page describes the different region types available in Spanner:
- Read-write regions
- Read-only regions
- Witness regions
Read-write regions
Each dual-region configuration has two read-write regions, each of which contains two read-write replicas and one witness replica. The read-write replicas behave similarly to the read-write replicas of a multi-region configuration.
Each multi-region configuration contains two read-write regions, each of which contains two read-write replicas.
One of these read-write regions is designated the default leader region. A leader is selected from the replicas in the default leader region for each split. In the event of a leader replica failure, the other replica in the default leader region automatically assumes leadership. In fact, leaders run health checks on themselves and can preemptively give up leadership if they detect they are unhealthy. In most cases, when the default leader region returns to a healthy state, it automatically re-assumes the leadership.
Writes are first processed in the default leader region. You can monitor the
percentage of replicas within a given region by
using the instance/leader_percentage_by_region
monitoring metric. For more
information, see Spanner metrics.
The second read-write region contains additional replicas that serve reads and participate in voting to commit writes. These additional replicas in the second read-write region are eligible to be leaders. In the unlikely event of the loss of all replicas in the default leader region, new leader replicas are chosen from the second read-write region.
You can configure the leader region of a database by following the instructions at Change the leader region of a database. For more information, see Configure the default leader region.
Read-only regions
Read-only regions contain read-only replicas, which can serve low-latency reads to clients that are outside of the read-write regions. Read-only replicas maintain a full copy of your data, which is replicated from read-write replicas. They don't participate in voting to commit writes and don't contribute to any write latency.
Some base multi-region configurations contain read-only replicas. You can also create a custom instance configuration, and add read-only replicas to your custom regional and multi-region instance configurations to scale reads and support low latency stale reads. All read-only replicas are subject to compute capacity and database storage costs. Furthermore, adding read-only replicas to an instance configuration doesn't change the Spanner SLAs of the instance configuration. For more information, see Read-only replicas.
Witness regions
A witness region contains a witness replica, which is used to form a write quorum and vote on writes. Every Spanner mutation requires a write quorum that's composed of a majority of voting replicas (for dual-region configurations, the quorum requires two replicas from both regions). Witnesses become important in the rare event that the read-write regions become unavailable. Only dual-region and multi-region configurations contain witness regions. For more information about leader regions and voting replicas, see Replication.
What's next
- Learn more about Regional, dual-region, and multi-region configurations.
- Learn more about Replication.
- Learn more about Google Cloud geography and regions.