Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Redis Difficulty: Advanced ClaudeChatGPTCursor

Redis Active-Active (CRDT) Geo-Replication Design Prompt

Design multi-region active-active Redis — CRDT semantics, conflict resolution, counters vs strings, and expiry pitfalls — for low-latency global writes.

Target user
Architects designing multi-region Redis writes
Difficulty
Advanced
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior distributed-systems and Redis expert who designs multi-region active-active Redis deployments (CRDT-based geo-replication) for production.

I will provide:
- The regions and the write pattern (which data is written where)
- Data types in use and the consistency each field needs
- Latency and availability targets per region
- Conflict-tolerance for each entity (last-writer-wins acceptable? counters must never lose increments?)

Your job:

1. **Set expectations.** Active-active Redis (Conflict-free Replicated Data Types) lets **every region accept writes locally** and converge asynchronously. It gives low local latency and survives region isolation, but it is **eventually consistent** — a read in region A may not yet see a write in region B. Say this plainly; if the app needs strong/linearizable consistency, active-active is the wrong model.
2. **Map each type to its CRDT merge rule:**
   - **Counters** (`INCR`/`DECRBY`) use a PN-counter: concurrent increments in different regions are **summed**, never lost. This is the headline feature.
   - **Strings** (`SET`) resolve by **last-write-wins** using synchronized clocks — concurrent sets to the same key: one silently wins.
   - **Sets / Hashes / Sorted sets** merge element-wise (add-wins on concurrent add/remove of the same element by default).
   - **Lists** preserve both concurrent inserts (no element lost) but ordering across regions is not guaranteed.
3. **Flag the LWW traps.** Anything modeled as a plain string (a JSON blob, a status field) loses concurrent edits. Reshape mutable multi-field objects into **hashes** so different fields written in different regions both survive.
4. **Handle expiry carefully.** TTLs replicate, but "the longer TTL / the delete wins" semantics differ from single-instance Redis. A key deleted in one region while written in another can resurface. Design so expiry is not used as a correctness mechanism.
5. **Sizing & bandwidth.** CRDT metadata adds per-key overhead vs plain Redis; cross-region replication consumes WAN bandwidth proportional to write rate. Estimate both.
6. **Choose write locality.** Prefer routing each entity's writes to a **home region** where natural, so LWW conflicts are rare; reserve true multi-region concurrent writes for counter-like data that merges cleanly.
7. **Failure modes.** Describe behavior under region isolation (local writes continue, converge on heal) and the reconciliation window applications must tolerate.

Deliverables: a per-entity table mapping data → Redis type → CRDT merge rule → conflict risk, a write-routing plan, an expiry policy, and a bandwidth/overhead estimate.

Mark DESTRUCTIVE: modeling mutable objects as single strings under concurrent regional writes (silent data loss via LWW), relying on TTL for correctness across regions, and `FLUSHALL` which propagates to every region.

---

Regions/write pattern: [DESCRIBE]
Types & consistency needs: [DESCRIBE]
Latency/availability targets: [DESCRIBE]

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Why this prompt works

Active-active Redis sells a seductive promise — write anywhere, low latency, survive a region outage — but that promise is built on CRDT merge rules that behave very differently per data type. Counters sum beautifully; plain strings quietly lose concurrent writes; TTLs behave unlike single-instance Redis. Teams that treat it like “regular Redis but replicated” ship silent data-loss bugs. This prompt maps every entity to its merge rule and conflict risk before a single key is written.

How to use it

  1. List the regions and where each entity is written so conflict likelihood is clear.
  2. Enumerate data types and required consistency to pick the right CRDT.
  3. State latency/availability targets to justify active-active at all.
  4. Say which entities can tolerate LWW vs which must never lose updates.

Per-type merge behavior

Counter (INCR/DECRBY) -> PN-counter: concurrent increments SUMMED, none lost
String  (SET)         -> Last-Write-Wins by clock: one concurrent write drops
Hash    (HSET)        -> per-field merge: different fields in diff regions BOTH survive
Set     (SADD/SREM)   -> element-wise, add-wins on concurrent add/remove
Sorted set            -> element-wise merge; scores by LWW per member
List    (LPUSH/RPUSH) -> concurrent inserts preserved; cross-region order not guaranteed

Modeling fix for LWW

# RISKY: whole object as one string -> concurrent regional writes lose data
redis-cli SET user:42 '{"name":"Ada","lastLogin":"...","region":"eu"}'

# SAFER: hash -> a field written in us-east and a field written in eu-west both merge
redis-cli HSET user:42 name Ada
redis-cli HSET user:42 lastLogin 2026-07-08T14:00:00Z   # written in eu-west
redis-cli HINCRBY user:42 loginCount 1                   # merges by summation

Common findings this catches

  • JSON blob in a string → concurrent-edit loss; reshape to a hash.
  • String counters via SET → lost increments; use INCR (PN-counter).
  • Read-your-write assumed cross-region → violated by eventual consistency.
  • TTL used for correctness → resurfacing keys across regions.
  • Everything written everywhere → avoidable LWW conflicts; add home-region routing.

When to escalate

  • Requirements demand strong/linearizable consistency — active-active cannot provide it.
  • Complex custom conflict resolution — may exceed built-in CRDT semantics.
  • WAN bandwidth from write rate becomes the bottleneck — revisit write locality and grain.

Related prompts

More Redis prompts & error guides

Browse every Redis prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.