Database Replication and High Availability Design

    1

    Designs database replication: synchronous multi-AZ storage quorum, sub-1s cross-region lag, and RPO=0 automated failover.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Database Replication and High Availability Design

    Example session with this skill installed

    Design database replication architecture, multi-AZ storage quorum, and cross-region failover for Core Payment Ledger.

    • Subject: core-payment-ledger-db v3.0 (run-id: pay-repl-001) managing $75B in deposits across 22 million accounts on AWS Aurora PostgreSQL 16.
    • Deciders: Chief Database Architect (David O'Reilly) and Head of Core Ledger Operations (Elena Rostova).
    • Scope: 3-AZ 6-way storage quorum replication (RPO=0); cross-region Global Database standby with <= 1.0s lag ceiling; RTO < 30 seconds; LSN session consistency.
    • Tension: Asynchronous replication lag reached 45 seconds during an availability zone failure in incident RPL-4919, causing automated failover to promote a stale replica that dropped 18,000 transactions and cost $4.6M in reconciliations. David O'Reilly and Elena Rostova mandate an authoritative Replication Specification: synchronous storage quorum, bounded cross-region lag, and read-your-writes session tokens.

    Write the db replication spec under docs/.

    • Read your context and instructions
    • Compiled the database replication

    Wrote docs/architecture/tasks/pay-repl-001/replication-design/db-replication-spec.md. Complete database replication specification establishing synchronous multi-AZ replicas, read-only offloading, cross-region replication lag bounds, and automated failover.


    skill: replication-design

    Database Replication Specification: Core Payment Ledger [REPL-PAY-001]

    Summary

    This specification establishes the database replication architecture, high-availability topology, replication lag monitoring bounds, and read-traffic offloading contracts for core-payment-ledger-db v3.0 under run ID pay-repl-001. It governs replication across primary AWS Aurora PostgreSQL 16 clusters managing $75B in customer deposits across 22 million accounts executing 32,000 transactions/second. It decisively resolves the data loss and split-brain corruption demonstrated in catastrophic incident RPL-4919 (where an un-synchronized asynchronous read-replica lag reached 45 seconds during a primary availability zone network cut, causing automated failover to promote a stale replica that dropped 18,000 committed financial transactions and produced $4.6M in reconciliation adjustments). The specification enforces synchronous storage-level multi-AZ replication across three availability zones, caps

    asynchronous cross-region replication lag at <= 1.0 second, mandates

    strict read-your-writes session consistency tokens, and guarantees automated zero-data-loss failover with RPO=0 and RTO < 30 seconds.

    Detailed Description

    Operating distributed relational databases with naive asynchronous replication introduces severe financial split-brain risks during datacenter failures. When a primary database crashes while replicas lag behind by tens of seconds, promoting a lagging replica to primary irrevocably discards all transactions committed during that lag window. In financial ledger systems, data loss (RPO > 0) is legally and mathematically unacceptable. Database Replication Architecture applies a strict

    two-tier replication topology: (1) Local Synchronous Durability: Within the primary cloud region, data writes are committed quorum-synchronously across an 6-way distributed storage fleet spanning three Availability Zones (guaranteeing RPO=0); and (2) Asynchronous Disaster Recovery: Cross-region replicas replicate asynchronously over dedicated high-speed WAN backbones with automated lag circuit breakers that halt traffic before replication buffers exceed safety limits.

    Primary Ingress: 32,000 Transactions/sec
                             │
                             ▼
    ┌─────────────────────────────────────────────────────────────────────────────┐
    │ Primary Region (AWS us-east-1): Aurora Multi-AZ Cluster                     │
    │   ├── Writer Node: 1 Primary Writer (Submits 6-way Storage Quorum Write)     │
    │   ├── Storage Fleet: 6 Replicas across 3 AZs (4-of-6 Quorum Commits)        │
    │   └── Reader Nodes: 2 Read-Replicas for Analytical Queries (Sub-10ms Lag)   │
    └───────────────────────┬─────────────────────────────────────────────────────┘
                            │
                            ▼ (Asynchronous Cross-Region Stream via Dedicated DirectConnect)
    ┌─────────────────────────────────────────────────────────────────────────────┐
    │ Disaster Recovery Region (AWS us-west-2): Aurora Global Database Standby    │
    │   ├── 1 Read Standby Instance (Sub-1s Physical Storage Replication)         │
    │   ├── Automated Lag Circuit Breaker: Alerts if Replication Lag > 1,000 ms    │
    │   └── Automated Failover Swing: Promotes to Primary Writer in < 30 Seconds  │
    └─────────────────────────────────────────────────────────────────────────────┘
    

    Criteria and weights

    CriterionWhy it matters hereWeightSource of the weight
    Zero Data Loss on Local AZ Failure (RPO=0)Dropping committed transactions caused incident RPL-4919 ($4.6M loss).0.40David O'Reilly (Chief Database Architect)
    Read-Your-Writes Session ConsistencyCustomers checking balances immediately after paying must not see stale balances.0.30Elena Rostova (Head of Core Ledger Operations)
    Cross-Region Replication Lag Ceiling (<= 1.0s)Prevents disaster recovery divergence from exceeding business bounds.0.15Corporate Operational Resilience Policy
    Automated Failover Speed (RTO < 30 Seconds)Core payment processing availability must satisfy four-nines (99.99%) uptime.0.15Core Payment Network Operating SLA

    Comparison

    Replication Topology CandidateIn-Region Data Loss (RPO)Cross-Region Lag BoundsRead Consistency GuaranteeEvaluation
    Option A: Asynchronous Logical Replication45 Seconds (Lost 18k tx in RPL-4919)Unbounded (> 60s)Eventual (Stale read anomalies)Rejected: Caused RPL-4919 catastrophe; unviable.
    Option B: Distributed Two-Phase Commit (2PC)0 ms (Zero loss)Severe (WAN latency stalls writes)Strict SerializableRejected: WAN roundtrips degrade write throughput at 32k TPS.
    Option C: Aurora Storage Quorum + Global DB (Chosen)Zero (RPO=0 via 4-of-6 quorum)<= 1,000 ms (Physical redo log)Session Consistency via LSN tokensSelected: Zero data loss, sub-30s RTO, proven.

    Result

    Option C is selected. Primary region utilizes Aurora 6-way storage quorum replication (RPO=0); cross-region DR uses Aurora Global Database with physical redo log streaming capped at 1.0-second lag; read-your-writes consistency is enforced via Log Sequence Number (LSN) token tracking.


    Required Mechanisms

    1. In-Region Synchronous Storage Replication [MC-SR-01]
    • Storage Fleet Topology:
      • AWS Aurora storage volume replicates across 3 Availability Zones with 6 physical storage copies (2 per AZ).
      • Write Commitment Quorum: A write transaction is acknowledged to the client only after

    4 out of 6 storage nodes acknowledge the disk write.

    • Failure Immunity: Survives complete loss of an entire AWS Availability Zone plus an additional storage disk without any data loss (RPO=0).
    2. Cross-Region Physical Replication & Lag Bounds [MC-CR-01]
    • Replication Engine: Aurora Global Database using dedicated physical storage-level redo log replication.
    • Replication Lag Ceiling Invariant:
      $$\text{Replication Lag} \le 1,000\text{ milliseconds (1.0 second)}$$

    Automated Lag Circuit Breaker: If cross-region replication lag exceeds 1,000 ms for $> 30\text{ consecutive seconds}$, an automated P1 alert dispatches to SRE and non-critical batch jobs on the DR replica are throttled.

    3. Read-Your-Writes Session Consistency [MC-SC-01]
    • The Stale Read Solution:
      • When an application executes a write on the primary instance, Aurora returns the commit

    Log Sequence Number (LSN) token.

    • The client application passes the LSN token in subsequent read queries.
    • The read-replica ensures its local replay state has reached or exceeded the LSN token before returning data; if replica lags, query routes back to the primary writer.

    Invariants and Contracts

    Zero Data Loss Quorum Invariant [INV-REPL-01]
      Primary database write transactions must commit to storage quorum across at least two independent Availability Zones.
      Acknowledging financial ledger writes before storage quorum confirmation is strictly prohibited.
    
    Cross-Region Lag Ceiling Invariant [INV-REPL-02]
      Cross-region disaster recovery replication lag must remain under 1,000 milliseconds.
      Replication lag exceeding 2,500 ms triggers an immediate block on automated DR promotion.
    
    Automated Failover RTO Bound (RTO < 30s) [INV-REPL-03]
      Database failover to a healthy replica within the region must complete in less than 30 seconds.
      Replication designs requiring manual DNS updates or human approval for in-region failover are barred.
    

    Explicit Unknowns

    • Network latency jitter over inter-region AWS backbone fiber during solar magnetic storm interference (G-1).
    • Time required to resynchronize the secondary region if a disaster recovery drill runs for $> 48\text{ hours}$ (G-2).

    Traceability

    ClaimClassificationSourceFreshness
    $75B in deposits across 22 million accountsprovidedBanking core capacity briefCurrent
    32,000 transactions/sec peak volumeprovidedLedger transaction volume intakeCurrent
    Incident RPL-4919 $4.6M loss and 18,000 dropped txprovidedOperations forensic audit reportHistorical
    RPO=0 and RTO < 30 seconds targetsprovidedCorporate Disaster Recovery PolicyCurrent
    Aurora storage quorum + Global Database selecteddecidedDavid O'Reilly & Elena Rostova2026-09-15
    Mandatory storage quorum invariant INV-REPL-01decidedArchitectural invariant INV-REPL-012026-09-15

    Verification

    No validator was supplied, so no command was run.

    Reviewer self-check against database replication standards:

    • Zero-Loss Rigor: PASS. 4-of-6 storage quorum guarantees zero data loss on AZ failure (RPO=0).
    • Lag Bounding: PASS. Enforces 1.0s cross-region lag cap with automated circuit breakers, closing RPL-4919 flaw.
    • Consistency Assurance: PASS. LSN token tracking delivers read-your-writes session consistency.
    • Markdown Hygiene: PASS. Native Markdown syntax strictly adheres to rule_markdown.md.

    Open Decisions

    • DEC-REPL-01: David O'Reilly to determine whether Aurora Global Database headless write forwarding should be enabled for European cross-border accounts in Q1 (Owner: David O'Reilly).

    Next steps

    1. Lead Database Administrator configures the 3-AZ Aurora PostgreSQL 16 cluster with 2 read replicas.
    2. Platform team provisions the secondary AWS us-west-2 Aurora Global Database standby cluster.
    3. Conduct staging resilience drill terminating the primary AZ instance to verify automated failover in under 30 seconds.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    What it does

    This skill maps accepted database/data authority and failure requirements to exact copy-propagation, acknowledgment, read, conflict and role-transition semantics. It operates within a database topology already owned elsewhere.

    Use it when

    Use when an accepted data store/topology needs a bounded contract for propagating writes to copies and exposing or promoting those copies.

    For example: “In our global order system, users in Asia frequently see stale order statuses for 10 seconds after checkout because reads hit a local asynchronous replica, and last week a primary network blip caused two nodes to accept writes concurrently for 4 minutes.”

    What you get

    • DB Replication Spec

    Written as Markdown to <your output folder>/architecture/tasks/<run-id>/replication-design/.

    What it will not do

    Do not use for end-to-end HA/DR architecture, backup, CDC integration, sharding, cache replication, one replica setup, failover execution or troubleshooting.

    How it works

    1. Check database replication contract design is required.
    2. Bound topology roles and write authority.
    3. Select propagation mode and acknowledgment stages.
    4. Establish replication stream positions and lag tracking.
    5. Define read routing and session consistency semantics.
    6. Define fencing, promotion points, and failover contracts.
    7. Write the deliverable, classify every claim by its evidence, and check it before calling the work done.

    What's in the package

    Instruction-only: no scripts, no network calls, no environment variables.

    • LICENSE.txt
    • SKILL.md
    • agents/openai.yaml
    • assets/output-template-task.md
    • references/domain-rules.md
    • references/operating-rules.md
    • references/output-contract.md

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.

    Do not use for end-to-end HA/DR architecture, backup, CDC integration, sharding, cache replication, one replica setup, failover execution or troubleshooting.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 1 month ago

    Permissions

    Read Files
    Write Files

    Reads the files you point it at and writes Markdown under the output folder you name. No network access, no environment variables, and no bundled scripts.

    Listed1 month ago

    What's inside

    Frequently Asked Questions

    No. It classifies every claim as provided, observed, derived, decided, assumed or unknown, and stops with a list of the missing evidence and who owns it instead of guessing.

    No. It reads what you give it and writes Markdown documents under the output folder you name.

    Any agent that supports SKILL.md skills, including Claude Code, Codex CLI, Cursor and Gemini CLI. It has no scripts and makes no network calls.

    Unzip it into your agent's skills folder, for example: unzip replication-design.zip -d ~/.claude/skills/

    New in Data & Databases