# Replication

The replication process forms an essential part of a disaster recovery (DR) plan.

SingleStore replicates data in the following situations.

* When you run your cluster in [high availability, redundancy-2 mode](https://docs.singlestore.com/db/v9.1/user-and-cluster-administration/high-availability-and-disaster-recovery/managing-high-availability.md), SingleStore replicates data from master to replica partitions in the same cluster.
* When you use the [REPLICATE DATABASE](https://docs.singlestore.com/db/v9.1/reference/sql-reference/operational-commands/replicate-database.md) command, SingleStore [replicates data across clusters](https://docs.singlestore.com/db/v9.1/user-and-cluster-administration/high-availability-and-disaster-recovery/replicating-data-across-clusters.md).

## Synchronous and Asynchronous Replication

## Synchronous Replication Debugging Flow

The diagram below shows what happens when an async alert is raised at the partition level. The replica refers to the leaf node that has the replica partition and the master is the master partition instance, which fails if the leaf node where it hosted goes offline, or is unable to communicate with the master aggregator (for example. due to network issues).

![](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/bltef282dcc021946f1/6a2c421f09d823755b29c45a/Sync_Replication_Debug_Flow-z5yLdx.png)

## High availability, Redundancy-2 mode

With high availability redundancy-2 replication, you can specify, using the [CREATE DATABASE](https://docs.singlestore.com/db/v9.1/reference/sql-reference/data-definition-language-ddl/create-database.md), [RESTORE DATABASE](https://docs.singlestore.com/db/v9.1/reference/sql-reference/operational-commands/restore-database.md) and [ALTER DATABASE](https://docs.singlestore.com/db/v9.1/reference/sql-reference/data-definition-language-ddl/alter-database.md) commands, whether replication from primary to replica partitions is synchronous or asynchronous. By default, synchronous replication is used. Synchronous replication from the primary partitions will complete on all replicas before the commit of the transaction is acknowledged to the client application.

Synchronous replication is usually no more than ten to twenty percent slower than asynchronous replication. However, SingleStore recommends using synchronous replication; it provides much stronger data consistency guarantees as compared to asynchronous replication.

If a database is using synchronous replication and its replica partition fails to respond within five seconds, the replica partition switches to asynchronous replication; this allows the replica partition to not block the current and future replication transactions. The replica partition does not resume failover until both of the following are true:

* The replica partition becomes responsive.
* The primary partition becomes responsive, if it was previously unresponsive.

When the replica partition resumes failover, it switches to synchronous replication.

## REPLICATE DATABASE

When you use the [REPLICATE DATABASE](https://docs.singlestore.com/db/v9.1/reference/sql-reference/operational-commands/replicate-database.md) command, you can only replicate asynchronously.

***

Modified at: September 8, 2022

Source: [/db/v9.1/user-and-cluster-administration/high-availability-and-disaster-recovery/replication-and-durability-concepts/replication/](https://docs.singlestore.com/db/v9.1/user-and-cluster-administration/high-availability-and-disaster-recovery/replication-and-durability-concepts/replication/)

(An index of the documentation is available at /llms.txt)
