Skip to content

Commit ee3211f

Browse files
Document how to use zone config extensions to remove read replicas (#22371)
* Document how to use Zone config extensions to remove read replicas Fixes DOC-15023 Co-authored-by: Florence Morris <58752716+florence-crl@users.noreply.github.com>
1 parent 7519047 commit ee3211f

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

src/current/v26.1/alter-database.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,12 @@ ALTER DATABASE movr CONFIGURE ZONE DISCARD;
746746
The following examples show:
747747

748748
- How to [override specific fields of a schema object's zone configs](#override-specific-fields-of-a-schema-objects-zone-configs).
749+
- How to [reduce storage costs by removing non-voting replicas](#reduce-storage-costs-by-removing-non-voting-replicas).
750+
- How you could [implement super regions](#implement-super-regions).
751+
- How to [minimize cross-region write latency](#minimize-cross-region-write-latency).
749752
- How something like the [Secondary regions]({% link {{ page.version.version }}/multiregion-overview.md %}#secondary-regions) multi-region abstraction could have been implemented using Zone Config Extensions. For this example, we will call it ["Failover regions"](#failover-regions).
750753
- How to [reset a region's Zone Config Extensions](#reset-a-regions-zone-config-extensions).
751754
- How to [discard a region's Zone Config Extensions](#discard-a-regions-zone-config-extensions).
752-
- How you could [implement super regions](#implement-super-regions).
753-
- How to [minimize cross-region write latency](#minimize-cross-region-write-latency).
754755

755756
{{site.data.alerts.callout_info}}
756757
We strongly recommend using the multi-region abstractions over "rolling your own" using Zone Config Extensions. These examples are provided to show the flexibility of Zone Config Extensions.
@@ -866,6 +867,53 @@ The `lease_preferences` field is now updated to include `us-west1`.
866867

867868
To remove the changes made in this example, [reset the Zone Config Extensions](#reset-a-regions-zone-config-extensions).
868869

870+
#### Reduce storage costs by removing non-voting replicas
871+
872+
In a [multi-region database]({% link {{ page.version.version }}/multiregion-overview.md %}), the default zone configuration may include additional [non-voting replicas]({% link {{ page.version.version }}/configure-replication-zones.md %}#num_voters) (for example, to support [follower reads]({% link {{ page.version.version }}/follower-reads.md %})). The database's [survival goal]({% link {{ page.version.version }}/multiregion-overview.md %}#survival-goals) depends only on the number of voting replicas (`num_voters`), not the total number of replicas (`num_replicas`).
873+
874+
By default, the `movr` database [as configured for this example](#setup) has a [zone survival goal]({% link {{ page.version.version }}/multiregion-survival-goals.md %}):
875+
876+
{% include_cached copy-clipboard.html %}
877+
~~~ sql
878+
SHOW SURVIVAL GOAL FROM DATABASE movr;
879+
~~~
880+
881+
~~~
882+
database | survival_goal
883+
-----------+----------------
884+
movr | zone
885+
(1 row)
886+
~~~
887+
888+
This means that the number of replicas (`num_replicas`) is greater than strictly necessary to support the zone survival goal, which you can confirm with [`SHOW ZONE CONFIGURATION`]({% link {{ page.version.version }}/show-zone-configurations.md %}):
889+
890+
{% include_cached copy-clipboard.html %}
891+
~~~ sql
892+
SHOW ZONE CONFIGURATION FROM DATABASE movr;
893+
~~~
894+
895+
~~~
896+
target | raw_config_sql
897+
----------------+-------------------------------------------------------------------------------------------
898+
DATABASE movr | ALTER DATABASE movr CONFIGURE ZONE USING
899+
| range_min_bytes = 134217728,
900+
| range_max_bytes = 536870912,
901+
| gc.ttlseconds = 14400,
902+
| num_replicas = 5,
903+
| num_voters = 3,
904+
| constraints = '{+region=europe-west1: 1, +region=us-east1: 1, +region=us-west1: 1}',
905+
| voter_constraints = '[+region=us-east1]',
906+
| lease_preferences = '[[+region=us-east1], [+region=us-west1]]'
907+
(1 row)
908+
~~~
909+
910+
If you want to reduce storage costs, and can accept losing the ability to perform [follower reads]({% link {{ page.version.version }}/follower-reads.md %}), use Zone Config Extensions to reduce the number of non-voting replicas by setting `num_replicas` equal to `num_voters`:
911+
912+
{% include_cached copy-clipboard.html %}
913+
~~~ sql
914+
ALTER DATABASE movr ALTER LOCALITY REGIONAL CONFIGURE ZONE USING num_replicas = 3;
915+
~~~
916+
869917
#### Implement super regions
870918

871919
In this example, [Zone Config Extensions]({% link {{ page.version.version }}/zone-config-extensions.md %}) are used to provide an alternative implementation of [super regions]({% link {{ page.version.version }}/multiregion-overview.md %}#super-regions), which are useful for [data domiciling]({% link {{ page.version.version }}/data-domiciling.md %}).

src/current/v26.1/zone-config-extensions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ We strongly recommend that most users use the [default multi-region SQL abstract
2424
- [`REGIONAL`]({% link {{ page.version.version }}/alter-database.md %}#parameters) extensions don't set [lease preferences]({% link {{ page.version.version }}/configure-replication-zones.md %}#lease_preferences).
2525
- [`REGIONAL IN`]({% link {{ page.version.version }}/alter-database.md %}#parameters) extensions don't set [lease preferences]({% link {{ page.version.version }}/configure-replication-zones.md %}#lease_preferences), nor do they set [replica constraints]({% link {{ page.version.version }}/configure-replication-zones.md %}#constraints) or [voter constraints]({% link {{ page.version.version }}/configure-replication-zones.md %}#voter_constraints) that would conflict with the original [home region]({% link {{ page.version.version }}/table-localities.md %}#regional-by-row-tables).
2626
- In no case will Zone Config Extensions change the [survival goals]({% link {{ page.version.version }}/multiregion-overview.md %}#survival-goals) for the database.
27+
- Zone Config Extensions can set [`num_replicas`]({% link {{ page.version.version }}/configure-replication-zones.md %}#num_replicas) as low as [`num_voters`]({% link {{ page.version.version }}/configure-replication-zones.md %}#num_voters), which removes non-voting replicas while preserving the database's survival goal.
2728
- They are composable. You can use Zone Config Extensions to build up approximations of many higher-level features. For an example, see [Failover regions]({% link {{ page.version.version }}/alter-database.md %}#failover-regions).
2829
- They are region scoped. When a Zone Config Extension is attached to a [database region]({% link {{ page.version.version }}/multiregion-overview.md %}#database-regions), any [`REGIONAL BY TABLE`]({% link {{ page.version.version }}/table-localities.md %}#regional-tables) or [`REGIONAL BY ROW`]({% link {{ page.version.version }}/table-localities.md %}#regional-by-row-tables) tables associated with that region will have their zone configurations updated according to the settings passed via the extension. As mentioned above, this updated config will also be persisted in the face of other multi-region configuration changes.
2930
- They are locality scoped. You can specify a Zone Config Extension that only applies to tables with certain [localities]({% link {{ page.version.version }}/multiregion-overview.md %}#table-localities). For example, to apply a Zone Config Extension to tables with the [`GLOBAL` locality]({% link {{ page.version.version }}/table-localities.md %}#global-tables), use [`ALTER DATABASE ... ALTER LOCALITY GLOBAL ...`]({% link {{ page.version.version }}/alter-database.md %}#alter-locality).

0 commit comments

Comments
 (0)