> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Cross-region replication

> Synchronously replicate a ClickHouse Cloud service to a second AWS region, so that it can fail over within minutes if its primary region becomes unavailable

Private preview

Cross-region replication keeps a second copy of a ClickHouse Cloud service's data in another AWS region and writes to both copies synchronously, so that the service can fail over to that region within minutes if its primary region becomes unavailable.

> [!NOTE]
>
> Cross-region replication is in private preview on AWS.  To request access, [join the waitlist](https://clickhouse.com/cloud/cross-region-waitlist) and tell us which regions you need.

## When should you use it?

A standard ClickHouse Cloud service runs in a single region.  If that region goes down, the service is unavailable until the region recovers, or until you restore a [backup](https://clickhouse.com/docs/products/cloud/features/backups/overview.md) that was [exported to another region](https://clickhouse.com/docs/products/cloud/guides/backups/bring-your-own-backup/export-backups-to-own-cloud-account.md) into a new service there.  The recovery point in that case is the most recent backup (up to 24 hours old with the default policy, or 6 hours with [configurable backups](https://clickhouse.com/docs/products/cloud/guides/backups/configurable-backups.md)), and recovery time grows with the amount of data to restore—hours for larger services. [Data resiliency](https://clickhouse.com/docs/products/cloud/reference/data-resiliency.md) covers that process in detail.

Cross-region replication is built for enterprises that need the highest level of availability guarantees—typically a recovery time objective (RTO) and recovery point objective (RPO) of less than an hour, which backup and restore can't deliver.  With the data already in the secondary region, there's nothing to restore.  Recovery time comes down to provisioning compute there (minutes), and the recovery point is the last part written to object storage.

If your recovery objectives are measured in hours, backups are enough and come without the [trade-offs](#trade-offs) of a second region.

## How it works

A cross-region service is active-passive. The primary region is active and serves all reads and writes, while the secondary region holds a complete copy of the data and takes over after a failover.  You choose both regions when you create the service, and they must be on the same continent (`us-east-1` and `us-west-2`, for example).

![Cross-region replication during normal operation: replicas in the primary region write every part to object storage in both regions, and one Keeper cluster spans three regions](https://mintcdn.com/private-7c7dfe99/bShpwT5mdatuYpXT/images/cloud/features/infrastructure/cross-region-replication-1.png?fit=max\&auto=format\&n=bShpwT5mdatuYpXT\&q=85\&s=8f1c761e6053fc489bd072428ea1f027)

*Fig. 1 - Cross-region replication during normal operation*

Replication is synchronous and works at the level of data parts.  Every part operation (creation, merges, and deletion) is applied to object storage in both regions, and an insert is acknowledged only once its part has been written to both.

Metadata is coordinated by a single [ClickHouse Keeper](https://clickhouse.com/docs/guides/oss/deployment-and-scaling/keeper/index.md) cluster that spans regions, with two nodes in the primary region, two in the secondary, and one in a third region. The third region holds no table data and runs no compute—its Keeper node is there so that the cluster keeps a quorum if any one region is lost.

Compute runs only in the active region. The secondary region has no replicas while it's passive (so it can't serve queries, read-only ones included).  Merges run in the primary region, and the merged parts are written to both regions like any other part.

## Failover and failback

Failover is manual (ie - ClickHouse Cloud won't fail a service over on its own).  When you trigger it, ClickHouse Cloud stops writing to the primary region, removes the primary region's Keeper nodes from the cluster, transfers Keeper leadership to the secondary region, and starts replicas there.

![The same service after a failover: replicas run in the secondary region, workloads connect to the secondary endpoint, and the primary region is unavailable](https://mintcdn.com/private-7c7dfe99/bShpwT5mdatuYpXT/images/cloud/features/infrastructure/cross-region-replication-2.png?fit=max\&auto=format\&n=bShpwT5mdatuYpXT\&q=85\&s=91c935ffcffba5917d46c3f6fbc3137b)

*Fig. 2 - The same service after a failover to the secondary region*

Each region has its own endpoint, so once the failover completes, point your applications at the secondary region's endpoint.  When the primary region is healthy again, you can fail back to it in the same way.

## Trade-offs

A cross-region service costs more to run than a single-region one, and its inserts are slower:

| Trade-off | Impact | Why |
| - | - | - |
| Storage | 2x storage cost | A full copy of the data is kept in each region |
| Network egress | Increased network egress cost | Every part is transferred to the secondary region |
| Insert latency | Inserts take longer to acknowledge | Each insert waits for its part to be written to the secondary region |

Merges rewrite data in the background and each merged part is transferred too, so egress is a multiple of the volume you insert.  The insert latency penalty depends on the distance between the two regions and on the shape of your insert workload.
