Skip to content

PATTERN Cited by 1 source

Active-active with single-execution guarantee

Pattern

Deploy processing infrastructure in multiple regions, all simultaneously live and capable of handling events, but enforce exactly-once execution via a distributed lock. This distinguishes the pattern from:

  • Naive active-active — both process, causing duplicate side effects.
  • Active-passive — secondary is idle until failover, wasting recovery time on cold-start.

The key insight: active-active availability and single-execution correctness are not contradictions if you add a coordination layer (distributed lock + idempotency record).

Mechanism

  1. Event arrives at both regions (via fan-out).
  2. First handler to acquire a conditional-write lock in a globally-replicated store wins.
  3. Winner executes business logic and records completion.
  4. Loser checks lock state, sees it's claimed, skips silently.
  5. If winner fails mid-execution, lock expires or stays un-completed — loser (on retry/delay) acquires and takes over.
Approach Availability Duplicate risk Failover speed
Active-passive One live, one idle None Slow (cold-start)
Naive active-active Both live High Instant
This pattern Both live None (lock-guarded) Fast (delay window)

Trade-offs

Pro Con
Zero-downtime failover — secondary is already warm Requires globally-replicated lock store (cost, complexity)
No duplicate side effects Replication lag bounds minimum failover delay
Both regions exercised continuously (no cold-start surprise) Lock contention possible under very high event rates

Seen in

Last updated · 590 distilled / 1,788 read