Skip to content

High Availability & Cross-DC Disaster Recovery (PSYNC2, Dual-Channel Sync & SWAPDB)

This guide explains how to deploy Engula 2.3.0 across multi-AZ high-availability topologies (Sentinel and 16,384-slot Cluster) and cross-datacenter (Cross-DC) asynchronous disaster-recovery links — detailing PSYNC2 offset-based resumable WAN replication, Dual-Channel Replication, 1.83s native whole-block fullsync with reconnect-storm protection, and zero-blackout double-buffered replica loading (repl-diskless-load swapdb).


1. High-Availability & Cross-DC Topology Matrix

Engula 2.3.0 implements the full Redis 7.2 and Valkey 7.2+ primary-replica, Sentinel, and 16,384-slot Cluster wire contracts (cross-DC disaster recovery uses single-primary asynchronous replication paired with remote DR replicas, Sentinel, or Cluster):

Topology Target Production Scenario Verified Failover & Sync Metrics
Replication + Sentinel Single-shard stateful workloads requiring automated failure detection and promotion 1 primary + 2 replicas + 3 Sentinels (down-after=5000ms): 5.55 s median RTO (vs. 5.50 s vanilla baseline); mixed-engine failover 6.0–6.5 s
16,384-Slot Cluster Horizontal sharding beyond single-host DRAM capacity (hundreds of GBs to multi-TB fleets) Unrestricted shard count in release builds; shard failover in 8.0 s; live reshard with 0.00% error rate
Cross-AZ / Cross-DC DR Replicas Off-site hot standby, regional disaster-recovery cutover, and non-intrusive shadow validation Bidirectional PSYNC2 offset-based stream resumption across WAN flaps; 12M-key native fullsync in 1.83 s with 86% smaller replication buffers

2. Eliminating the Cross-DC "Infinite Fullsync Death Spiral"

Over high-latency WAN links, large vanilla Redis instances frequently fall into endless FULLRESYNC retry loops when a link flap overflows the backlog and subsequent 30–60+ s RDB transfers blow through client-output-buffer-limit replica. Engula 2.3.0 eliminates that failure mode with four shipped kernel mechanisms:

2.1 Offset-Based Resumable Stream Replication (PSYNC2 + repl-backlog-size)

Across transient WAN link flaps and Sentinel/Cluster primary promotions (replid / replid2 history tracking), reconnecting replicas send PSYNC <replid> <offset>:

  • Whenever the missed write window fits inside repl-backlog-size, the primary replies +CONTINUE and resumes streaming incremental commands from the exact byte offset with zero RDB re-transmission (verified bidirectionally across Engula 2.3.0 ↔ Redis 7.2 disconnects and failovers).

2.2 Capability-Negotiated 1.83s Native Fullsync & Reconnect-Storm Resistance

When a fresh replica attaches or a long WAN outage exceeds the backlog, replicas with engula-rdb 1 advertise REPLCONF capa engula-rdb during handshake:

  • Homogeneous Sub-2s Fullsync: When all waiting replicas in the batch support engula-rdb, the primary streams pre-compressed blocks directly (12M × 256 B keys over diskless sync completes in 1.83 s at 707 MB primary peak PSS vs. 29.3 s and 4,487 MB on Redis 7.2.14 — 16.0× faster and 84% lower primary RAM).
  • Dual-Replica Reconnect Storm Under Live Load: With 2 replicas reconnecting simultaneously under 50,000 ops/s live traffic, Engula 2.3.0 finishes fullsync in 2.18 s / 3.31 s (vs. 42.5 s / 62.3 s on Redis 7.2.14) while holding foreground client P99 latency at 0.36 ms (vs. 5.89 ms). On the public 10.37M-key storm benchmark, peak replication buffer drops by 86% (27.9 MB vs. 200.2 MB), preventing secondary buffer-limit disconnects.
  • Automatic Fallback in Mixed Batches: If any waiting replica in the batch is vanilla Redis 7.2 / Valkey (or has engula-rdb 0), the primary intersects batch capabilities and falls back to standard REDIS0011 RDB (34.3 s on 12M keys due to decompression — stagger homogeneous and legacy replicas into separate sync batches during cross-DC migrations).

2.3 Dual-Channel Replication (dual-channel-replication-enabled)

Inherited from Valkey 8.1.8 and integrated with engula-rdb capability negotiation: enabling dual-channel-replication-enabled yes streams the RDB snapshot over a dedicated RDB connection while concurrently streaming live incremental writes over the main replication channel, preventing primary output-buffer pileups during WAN fullsyncs.

2.4 Isolated Double-Buffered Replica Cutover (repl-diskless-load swapdb)

With repl-diskless-load swapdb, a replica loads an incoming fullsync into an isolated preload dataset while its active dataset continues serving read traffic without a cold/empty blackout window:

  • Clean Rollback on Mid-RDB Network Drops: If an initial RDB transfer drops mid-stream (socket reset / EOF), Engula 2.3.0 cleanly discards the isolated preload dataset while keeping the active dataset serving untouched, then restarts capability negotiation and a fresh whole-snapshot sync upon reconnect. (Note: resumable byte-offset continuation applies to PSYNC2 incremental command streams across disconnects/failovers; an aborted mid-RDB fullsync restarts cleanly rather than resuming from an internal RDB file byte offset.)

3. Production Configuration Templates (WAN DR, Sentinel & Cluster)

3.1 Cross-AZ / Cross-DC Primary & Replica Baseline

1# Primary and replica WAN resilience baseline
2engula-rdb 1
3repl-diskless-sync yes
4repl-diskless-sync-delay 5
5dual-channel-replication-enabled yes
6
7# Size replication backlog to 512mb–1gb on write-heavy WAN shards to absorb multi-minute flaps via PSYNC2
8repl-backlog-size 512mb
9repl-backlog-ttl 3600
10
11# Raise replica output-buffer ceiling for high bandwidth-delay WAN links
12client-output-buffer-limit replica 1gb 512mb 60
13
14# Isolate incoming fullsyncs in a preload dataset so active replica reads never black out
15repl-diskless-load swapdb

For dedicated remote DR replicas that should not be auto-promoted during local AZ blips, set replica-priority 0 until an explicit regional DR switchover is initiated.

3.2 Sentinel Automatic Failover Baseline

1port 26379
2sentinel monitor mymaster 10.0.0.10 6379 2
3sentinel auth-pass mymaster a-strong-random-password
4sentinel down-after-milliseconds mymaster 5000
5sentinel failover-timeout mymaster 60000
6sentinel parallel-syncs mymaster 1

Deploy an odd number of Sentinel instances (3 or 5) across independent failure domains so a single AZ partition never stalls quorum election.

3.3 16,384-Slot Cluster Bootstrap & Live Resharding

1port 6379
2cluster-enabled yes
3cluster-config-file nodes.conf
4cluster-node-timeout 15000
5dir /var/lib/engula-cluster

Bootstrap and reshard using standard redis-cli --cluster commands (for mixed-cluster shard consolidation and live slot migration, see Mixed-Cluster Live Slot Migration):

1redis-cli --cluster create \
2  10.0.0.1:6379 10.0.0.2:6379 10.0.0.3:6379 \
3  10.0.0.4:6379 10.0.0.5:6379 10.0.0.6:6379 \
4  --cluster-replicas 1

4. Pre-Launch HA & DR Drill Verification

  1. Verify PSYNC2 Stream Resumption: Check redis-cli INFO replication for master_link_status:up and zero sustained offset lag; inject a brief network cut and confirm INFO stats | grep sync_partial_ok increments without incrementing sync_full.
  2. Verify Failover RTO: Kill or isolate a staging primary and confirm Sentinel or Cluster promotes a replica within seconds and cleanly re-attaches the former primary as a replica upon recovery.
  3. Bound Asynchronous RPO: As in vanilla Redis 7.2 / Valkey, replication is asynchronous; evaluate min-replicas-to-write and min-replicas-max-lag when bounding writes on an isolated primary.

Related: Backup & Restore · Zero-Downtime Rolling Upgrade · Incident Triage & Fail-Stop Playbook