Architecture
High Availability

Replication and Failover

Primary-replica replication with configurable consistency, automatic failover, and lag monitoring.

Replication Architecture

Primary-replica data flow with backlog management

Mirror Groups

A mirror group is a set of nodes maintaining identical copies of data. One node is the primary (handles writes), others are replicas (serve reads).

SYNC

Wait for ALL replicas to acknowledge.

  • • Highest durability
  • • Highest latency
  • • For critical data

SEMI_SYNC
Default

Wait for at least ONE replica.

  • • Good durability
  • • Moderate latency
  • • Recommended

ASYNC

Fire and forget to replicas.

  • • Eventual consistency
  • • Lowest latency
  • • For high throughput

Replication Flow

  1. 1Write arrives at primary node
  2. 2Primary writes to local storage + WAL
  3. 3WAL entry added to BacklogManager queue
  4. 4BacklogManager streams to replicas
  5. 5Replicas apply changes, send ACK
  6. 6Primary confirms write (based on consistency level)

Automatic Failover

// MirrorGroupManager failover configuration
{
  "failover": {
    "enabled": true,
    "detectionInterval": 5000,      // Health check every 5s
    "failureThreshold": 3,          // 3 missed checks = failure
    "electionTimeout": 10000,       // 10s for election

    "priorityList": [               // Preferred failover order
      "node-2",
      "node-3"
    ],

    "requiresQuorum": true,         // Majority must agree
    "fencePreviousPrimary": true    // Prevent split-brain
  }
}

Lag Monitoring

Replication Lag Metrics

MetricDescriptionAlert Threshold
lag_bytesBacklog size in bytes> 100MB
lag_entriesNumber of pending entries> 10,000
lag_secondsTime behind primary> 30s

Recovery Process

Replica Recovery

  1. 1. Reconnect: Replica connects to new/existing primary
  2. 2. Compare: Exchange sequence numbers to find divergence
  3. 3. Catch-up: Stream missing entries from backlog
  4. 4. Verify: Checksum validation of recovered state
  5. 5. Ready: Replica marked healthy, added to read pool