Skip to content

KeyDB — multi-master Redis-compatible cache

KeyDB as a Redis-protocol alternative with built-in active-active multi-master replication — when it makes sense, when it does not, and the production gotchas.

KeyDB is a fork of Redis that adds active-active multi-master replication, threaded I/O, and a few smaller features — all while speaking the Redis 6 protocol so existing clients work unchanged. For a class of deployments — multi-region writes, “every node accepts SETs and converges” — KeyDB removes the operational ceremony of Redis Cluster or Sentinel-style failover. This article is the honest assessment we give clients evaluating it: when KeyDB earns the swap, when it does not, and what to watch.

How to verify

Check whether you already have KeyDB or upstream Redis, and what mode it is running in.

redis-cli INFO server | grep -i 'redis_version\|keydb_version\|os'
redis-cli INFO replication
redis-cli CONFIG GET "active-replica"
redis-cli CONFIG GET "multi-master"

If INFO server shows keydb_version, you have KeyDB. If active-replica yes and multi-master yes, the node is configured for active-active.

What’s happening

Upstream Redis was single-threaded for command processing (Redis 7 added some threading for I/O but keeps the single-writer model). KeyDB threads command execution across multiple worker threads, which lifts the CPU ceiling on a single node from “one core” to “however many you give it.” For workloads that hit CPU before they hit memory, this matters.

For replication, upstream Redis offers primary/replica (with Sentinel for failover) or Redis Cluster (sharded with replicas per shard, primary-elect per shard). Neither offers active-active — writes always land on one primary per key, and a failover is a discrete event with a short unavailability window.

KeyDB’s active-replica mode lets every node accept writes. Replication is bi-directional; writes are logged and shipped to peers, who apply them. Conflicts (concurrent writes to the same key from different nodes) are resolved last-writer-wins by timestamp. This is great for counter-style workloads and per-region session caches, and terrible for “we treat Redis as the source of truth for inventory” — the last-writer-wins semantics will quietly clobber legitimate updates.

The protocol is wire-compatible with Redis 6. Clients do not need to change, and you can put KeyDB behind a HAProxy that fronts upstream Redis without the clients noticing.

The decision

  1. Pick KeyDB when: you have multi-region or multi-DC writes where the application can tolerate last-writer-wins, you want threaded performance on a single fat node, or you want to avoid running Sentinel/Cluster operationally. The wire protocol compatibility is the single biggest selling point — migration is “swap the binary.”

  2. Stay on upstream Redis when: your workload depends on Redis modules (RedisJSON, RediSearch — KeyDB has partial coverage but lags), you use Redis Streams as a queue with consumer groups (KeyDB supports them but the multi-master semantics are not what you want for ordered consumption), or you run on managed Redis (ElastiCache, MemoryDB) where KeyDB is not an option.

  3. Hybrid pattern. A common deployment is upstream Redis for the cache (single-primary, replica per AZ) and KeyDB for region-local session stores that converge across regions. The two systems do not share data — they sit in separate paths in the application.

  4. Active-replica setup. Configure each node with the other as replica-of and enable both directions.

    # On node A (10.0.0.1):
    keydb-server --multi-master yes --active-replica yes \
                 --replicaof 10.0.0.2 6379 \
                 --port 6379 --bind 0.0.0.0
    
    # On node B (10.0.0.2):
    keydb-server --multi-master yes --active-replica yes \
                 --replicaof 10.0.0.1 6379 \
                 --port 6379 --bind 0.0.0.0
    
    # Verify replication is bi-directional:
    redis-cli -h 10.0.0.1 INFO replication | grep -E 'role|connected_slaves|master_link'
    redis-cli -h 10.0.0.1 SET test:a "from-A"
    redis-cli -h 10.0.0.2 GET test:a
    redis-cli -h 10.0.0.2 SET test:b "from-B"
    redis-cli -h 10.0.0.1 GET test:b
  5. Wire the client. Most Redis clients accept a list of nodes — point them at the local KeyDB and let the application read/write whichever node is nearest.

    # Python redis-py
    import redis
    r = redis.Redis(host='keydb.local', port=6379, decode_responses=True)
    r.set('cart:42', '{"item": "sku-1"}')

Common pitfalls

  • Treating active-active as “consensus” — it is not. Concurrent conflicting writes are resolved last-writer-wins by timestamp; clock skew between nodes becomes a correctness issue. Run NTP tightly and budget for it.
  • Running KeyDB on the same nodes as the application and letting the threaded workers compete with the app for CPU.
  • Enabling active-replica without multi-master (or vice versa) — both must be on for bi-directional writes to propagate.
  • Using AOF with appendfsync always on a write-heavy node — the disk fsync becomes the throughput bottleneck and you lose the threaded performance advantage.
  • Migrating from upstream Redis without checking module compatibility — RedisJSON commands may silently no-op or error on KeyDB depending on the version.

In the engagements we run, KeyDB shows up where there is a specific case for it — usually a multi-region cache that the team does not want to operate behind a custom replicator. For most clients, upstream Redis with Sentinel or Cluster is the right answer; the choice is one we work through with the engineering team. See managed operations for how Stack Harbor runs both in production.