Databases 12 min read

Design and Implementation of Bidirectional Redis Synchronization Across IDC: Cycle Break, LWW, Vector Clock, Tombstone, GC, and Expire

This article details Ctrip's practical design and implementation of a bidirectional Redis synchronization system across data centers, covering replication loop breaking, conflict resolution with Last Write Wins and Vector Clocks, tombstone handling, garbage collection strategies, and expiration policies to ensure data consistency.

Ctrip Technology
Ctrip Technology
Ctrip Technology
Design and Implementation of Bidirectional Redis Synchronization Across IDC: Cycle Break, LWW, Vector Clock, Tombstone, GC, and Expire

Introduction: The article builds on a previous post about Ctrip's Redis cross‑IDC multi‑directional synchronization, focusing on practical design details and solutions.

1. Cycle Break explains replication loops in a three‑node bidirectional setup, the problems of network storms and data inconsistency, and proposes filtering based on client‑origin flags to break the infinite loop.

2. Last Write Wins & Vector Clock describes conflict scenarios, the simple LWW rule, its limitations due to clock skew, and introduces logical vector clocks as a more reliable way to order operations.

3. Tombstone discusses the challenge of delete vs. update conflicts and presents the tombstone mechanism for logical deletion, enabling later reconciliation.

4. Garbage Collection (GC) examines how tombstones accumulate, outlines root‑set and reference‑counting GC methods, and explains how vector clocks help determine when a tombstone can be safely removed.

5. Expire analyzes cache expiration in a bidirectional sync, why inconsistent expire times do not break data consistency, and the trade‑offs of enforcing uniform expiration.

Conclusion summarizes the step‑by‑step review of building a distributed key‑value system and hints at future topics such as ZGC colored pointers.

distributed systemsRedisGarbage Collectiondata consistencyTombstoneCRDTvector clock
Ctrip Technology
Written by

Ctrip Technology

Official Ctrip Technology account, sharing and discussing growth.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.