Sign InTry Free

Local Read under Three Data Centers Deployment

In the model of three data centers, a Region has three replicas which are isolated in each data center. However, due to the requirement of strongly consistent read, TiDB must access the Leader replica of the corresponding data for every query. If the query is generated in a data center different from that of the Leader replica, TiDB needs to read data from another data center, thus causing the access latency to increase.

This document describes how to use the Stale Read feature to avoid cross-center access and reduce the access latency at the expense of real-time data availability.

Deploy a TiDB cluster of three data centers

For the three-data-center deployment method, refer to Multiple Data Centers in One City Deployment.

Note that if both the TiKV and TiDB nodes have the configuration item labels configured, the TiKV and TiDB nodes in the same data center must have the same value for the zone label. For example, if a TiKV node and a TiDB node are both in the data center dc-1, then the two nodes need to be configured with the following label:

[labels] zone=dc-1

Perform local read using Stale Read

Stale Read is a mechanism that TiDB provides for the users to read historical data. Using this mechanism, you can read the corresponding historical data of a specific point in time or within a specified time range, and thus save the latency brought by data replication between storage nodes. When using Stale Read in some scenarios of geo-distributed deployment, TiDB accesses the replica in the current data center to read the corresponding data at the expense of some real-time performance, which avoids network latency brought by cross-center connection and reduces the access latency for the entire query process.

When TiDB receives a Stale Read query, if the zone label of that TiDB node is configured, then TiDB sends the request to the TiKV node with the same zone label where the corresponding data replica resides.

For how to perform Stale Read, see Perform Stale Read using the AS OF TIMESTAMP clause.

Download PDF
One-stop & interactive experience of TiDB's capabilities WITHOUT registration.
TiDB Dedicated
TiDB Serverless
Get Demo
Get Started
© 2024 PingCAP. All Rights Reserved.
Privacy Policy.