Databases 21 min read

How JinS Achieves Multi‑Region Data Consistency and High Performance

Facing scalability limits, disaster risks, and latency in single‑region setups, OPPO built the JinS data‑sync framework, detailing its multi‑region challenges, design principles, modular architecture, consistency models, crash‑safe 2PC mechanisms, file‑queue optimizations, relay‑log handling, and performance gains over open‑source and commercial alternatives.

dbaplus Community
dbaplus Community
dbaplus Community
How JinS Achieves Multi‑Region Data Consistency and High Performance

Background

Rapid business growth forces many companies to move beyond single‑region architectures, which suffer from limited scalability, regional outages, and high latency.

Challenges of Multi‑Active Deployments

Conflicts when writing data across multiple locations.

Network latency and reliability over long distances.

Data‑consistency problems during synchronization.

Idempotency of synchronization.

Data reuse at the synchronization hub.

Multi‑Active Principles

Business Cohesion: Each complete business flow must run within a single data center to ensure low latency and fast state transitions.

Availability First: During failover, system availability is prioritized; temporary inconsistency is tolerated and repaired later.

Data Correctness: On failures, abnormal data conflicts trigger manual intervention to guarantee correctness.

Product Features of JinS

Bidirectional Sync: Real‑time incremental synchronization between data sources.

Unidirectional Sync: MySQL → MySQL, MySQL → Redis, supporting disaster‑recovery and heterogeneous sync.

Data Subscription: Cache notifications, asynchronous decoupling, real‑time ETL, etc.

Consistency Check: End‑to‑end MySQL consistency verification and repair.

Data Migration: MySQL and heterogeneous migrations.

Consistency Assurance Exploration

1. Architecture Design

The data‑sync architecture consists of a Subscription Module (parser, sink, store, registry, monitor, protocol) and a Consumption Module (input, filter, output, registry, monitor). Supporting services include a Manager platform, Consul for service registration, and Prometheus/Grafana/AlertManager for monitoring.

Architecture diagram
Architecture diagram

2. Microkernel Architecture

The system adopts a plugin‑based microkernel design similar to Eclipse, UNIX, or Dubbo, separating core services (plugin loading, registration, communication) from business‑specific plugins.

Microkernel diagram
Microkernel diagram

3. Data‑Sync Architecture

The consumption module mirrors the microkernel approach, making components like registry, monitor, input, filter, and output pluggable. Output plugins follow the Java SPI/Dubbo SPI pattern (interface + strategy + config file).

Data‑sync plugin diagram
Data‑sync plugin diagram

Consistency Model Exploration

Sequential Consistency: Guarantees order within a process and across nodes.

Linearizability: Provides a single‑copy abstraction where all operations appear atomic.

Crash‑Safe via Two‑Phase Commit (2PC)

MySQL’s redo log and binlog are kept consistent using a 2PC protocol. The consumption module acts as the coordinator and the subscription module as the participant, ensuring that either both redo and binlog are persisted or both are rolled back.

2PC diagram
2PC diagram

Bidirectional Consistency

When both sites can modify the same record, a pre‑write consensus (e.g., Paxos) orders writes, and a post‑write reconciliation resolves conflicts using a trusted‑source rule (e.g., latest timestamp) and a conflict pool.

Bidirectional consistency diagram
Bidirectional consistency diagram

Single‑Loop Scheme

For low‑volume sites, a ring‑shaped synchronization loop guarantees eventual consistency, though network delays may cause version alternation or loss.

Single‑loop scheme
Single‑loop scheme

Practical Optimizations

1. File Storage

An MMap‑based file queue with index files reduces pressure on downstream databases. Initial read‑write‑lock implementation yielded ~800 qps; switching to a lock‑free design using ByteBuffer for writes and MMapByteBuffer for reads increased throughput to ~20 k qps.

File queue performance
File queue performance

2. Relay Log

Inspired by MySQL’s relay‑log, JinS separates I/O and SQL threads, using a relay log in the store and a ring buffer for consumption, reducing network impact.

Relay log architecture
Relay log architecture

3. Two‑Phase Lock

InnoDB row locks are held until transaction end. By postponing lock acquisition and merging DML statements for the same primary key, lock wait time is reduced. Batch processing of 1 000 inserts drops from 13 000 ms to 500 ms.

Two‑phase lock performance
Two‑phase lock performance

Performance Metrics

Benchmarks against leading open‑source and commercial solutions show JinS achieving roughly double the throughput of open‑source alternatives and about 30 % lower throughput than commercial products, while offering higher stability (99.999 % availability, second‑level cross‑region latency).

Performance comparison
Performance comparison

Conclusion

Compared with open‑source products, JinS delivers roughly a 2× performance boost.

Against commercial products, performance is about 30 % lower, but stability is higher.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Distributed Systemsdata synchronizationConsistencyDatabase ReplicationJinSmulti‑region
dbaplus Community
Written by

dbaplus Community

Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.

0 followers
Reader feedback

How this landed with the community

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.