Global Distributed Cache for Tair is an active geo-redundancy database system developed in-house by Alibaba Cloud and built on Tair (Redis OSS-compatible). It supports business scenarios where multiple sites in different regions serve traffic simultaneously, and helps enterprises replicate Alibaba's active geo-redundancy architecture. This guide shows how to measure the synchronization latency between child instances in different regions using the tairgdn-latencytest tool.
How it works
The tairgdn-latencytest tool measures latency by comparing two timestamps: the UNIX timestamp stored as a key's value when data is written to the source instance, and the timestamp when that key is read from the destination instance. The difference between the two is the synchronization latency.
Data flows from the source child instance (write side) to the destination child instance (read side). Start the read command on the destination first so it is ready to capture synchronized keys as they arrive.
For cross-continental synchronization, round-trip time (RTT) is the dominant factor. Expect latency between a few hundred milliseconds and several seconds, depending on carrier networks and egress routing. To check current network latency between regions, see the NIS console.
Prerequisites
Before you begin, ensure that you have:
Two child instances in different regions. The examples in this guide use China (Beijing) as the source and China (Shenzhen) as the destination.
Two Elastic Compute Service (ECS) instances with Python 3 installed — one per region. Each ECS instance must be in the same region and zone as its corresponding child instance and connected through the same virtual private cloud (VPC).
The IP address of each ECS instance added to the whitelist of the child instance in the corresponding region. For details, see Set an IP address whitelist.
Recommended test environment
| Component | Recommended configuration |
|---|---|
| Child instance architecture | Standard architecture (non-cluster). For cluster architecture, overall performance scales by at least n times when keys are evenly distributed. See Standard architecture. |
| Child instance type | Instance type has little effect on results. A 1 GB master-replica instance is sufficient. See Memory-optimized (Standard architecture). |
| Child instance version | Version has little effect on results. |
Install the test tool
Run the following command on both ECS instances:
pip install tairgdn-latencytestTest synchronization latency
The following steps test latency for data flowing from the China (Beijing) child instance to the China (Shenzhen) child instance. Use the same approach for other region pairs.
Clear the database before each test. Run tests only on a test instance. Do not exceed the write queries per second (QPS) limit. For the limit, see Global Distributed Cache.
Step 1: Start the read command on the destination (Shenzhen)
Log on to the ECS instance in the China (Shenzhen) region and run:
tairgdn-latencytest read -h {host} -p {port} -u {username} -a {password} -n {keynumber}This command waits for keys synchronized from the Beijing instance, reads them, and calculates latency.
| Parameter | Description |
|---|---|
{host} | Private endpoint of the Shenzhen child instance. To find the endpoint, see View endpoints. |
{port} | Port of the Shenzhen child instance. Default: 6379. |
{username} | Username for the Shenzhen child instance. |
{password} | Password for the Shenzhen child instance. If you created a new account, use the <username>:<password> format — for example, admin:Rp829dlwa. |
{keynumber} | Number of keys to read. Must match the value used in the write command. |
Step 2: Start the write command on the source (Beijing)
Log on to the ECS instance in the China (Beijing) region and run:
tairgdn-latencytest write -h {host} -p {port} -u {username} -a {password} -n {keynumber} -P 16 -c 16This command continuously writes keys to the Beijing instance, using incremental integers as key names and UNIX timestamps as key values.
| Parameter | Description |
|---|---|
{host} | Private endpoint of the Beijing child instance. To find the endpoint, see View endpoints. |
{port} | Port of the Beijing child instance. Default: 6379. |
{username} | Username for the Beijing child instance. |
{password} | Password for the Beijing child instance. If you created a new account, use the <username>:<password> format — for example, admin:Rp829dlwa. |
{keynumber} | Number of keys to write. Must match the value used in the read command. |
-P 16 | Pipeline depth for write operations. |
-c 16 | Number of connections for write operations. To adjust write QPS, change -P and -c. |
Step 3: Collect results
Wait for the read command on the Shenzhen ECS instance to finish. It prints the synchronization latency from the Beijing child instance to the Shenzhen child instance.