# Two data centers within the same city (A)


![left](./student-guide/diagram/29-Two-center-structure-in-the-same-city-01-01.png)
------------------------------------------------------------

primary-replicas: is the number of voter replicas in the primary datacenter.
dr-replicas is the number of voter replicas from the datacenter.
The wait-store-timeout is the wait time to switch to asynchronous replication mode in the event of network isolation or failure. If there is no recover after this time, it automatically switches to asynchronous replication mode. The default time is 60 seconds.

In the scenario of on-premises deployment, TiDB usually adopts a multi-center deployment scheme to ensure high availability and disaster recovery capabilities. The multi-center deployment scheme includes a variety of deployment models, such as a three-center deployment model in two locations and a three-center deployment model in the same city. This article describes the two-center deployment option in the same city, which is to deploy two data centers in one city at a lower cost, and can also meet high availability and disaster recovery requirements. The deployment scenario uses an adaptive synchronization mode, Data Replication Auto Synchronous, or DR Auto-Sync for short.
In a two-center deployment scenario, two data centers are within 50 km of each other, typically in the same city or two adjacent cities (such as Beijing and Langfang), with a network connection latency of less than 1.5 ms and a bandwidth greater than 10 Gbps between the data centers.

Features:
The same city network has easy latency (less than 1.5 ms) and bandwidth of 10 megabits.
Services are available at each center. (hyperactive).
Has the ability to change state.

Requirements:
The primary center on the PD should be labeled Primary, and the disaster recovery center should be labeled DR.
Synchronously replicate TiKV landing data that requires DR tags.

State transition:
The replication mode of a cluster can automatically and adaptively switch between three states:
- When everything is normal in the cluster, it enters synchronous replication mode to maximize data integrity in the disaster recovery room.
- When the network of the computer room is disconnected or the disaster recovery room fails as a whole, the cluster will enter an asynchronous replication state after a period of protection window set in advance to ensure the availability of the business.
- When the computer room network is reconnected or the disaster room is restored as a whole, the TiKV nodes of the disaster recover room will rejoin the cluster, gradually synchronizing the data and eventually switching to synchronous replication mode.

The detailed process of state transition is as follows:
1. Initialization: When the cluster is first started, it is in sync (synchronous replication) mode. PD will send messages to TiKV, and all TiKV nodes will work strictly according to the sync mode requirements.