Scripts2026年4月15日·1 分钟阅读

KeyDB — Multithreaded Drop-In Redis Replacement

A fully Redis-compatible fork that is multithreaded by design, supports active-active replication, and delivers up to 5x the throughput of Redis on modern multi-core servers without changing a line of client code.

Introduction

KeyDB is a high-performance fork of Redis that adds native multithreading, active-active replication and FLASH tiered storage while staying 100% compatible with the Redis protocol, data types and client libraries. It is for teams that love Redis but have outgrown its single-threaded event loop on modern 32-core servers.

What KeyDB Does

  • Runs the Redis protocol on multiple worker threads that share the keyspace.
  • Supports active-active master-master replication with last-writer-wins conflict resolution.
  • Adds FLASH, an optional NVMe-backed tier that keeps warm keys in RAM and cold keys on SSD.
  • Exposes all Redis data structures: strings, hashes, lists, sets, sorted sets, streams, hyperloglogs, bitmaps, geo.
  • Ships Lua scripting, pub/sub, cluster mode, ACLs and TLS — exactly like Redis.

Architecture Overview

Each worker thread handles its own connections and runs an event loop. Shared data structures use fine-grained spinlocks and a global key lock that is held only briefly, letting many cores execute commands concurrently. Active replication exchanges writes both ways continuously, so two masters in different regions stay in sync without a manual failover. FLASH uses an LSM-backed layer so cold entries spill to disk transparently.

Self-Hosting & Configuration

  • Install from apt (eqalpha/keydb PPA), yum, Docker image, or build from source.
  • Set server-threads to ~N physical cores minus 1 for the best throughput.
  • Enable multi-master yes + active-replica yes for read/write on both regions.
  • Use storage-provider flash /data/keydb-flash to unlock FLASH tiered storage.
  • Tune maxmemory-policy, tcp-backlog and tcp-keepalive as you would with Redis.

Key Features

  • Up to 5x Redis throughput on 16+ core machines with no client changes.
  • Multi-master replication with sub-millisecond convergence in a single DC.
  • FLASH tiered storage for caches far larger than RAM.
  • Redis 7-level command compatibility, Sentinel and Cluster protocols supported.
  • Drop-in: existing monitoring (redis_exporter, redis-cli) works unchanged.

Comparison with Similar Tools

  • Redis 7 — canonical upstream; now I/O-threaded but not yet fully multithreaded.
  • Valkey — Linux Foundation fork of Redis 7.2; different governance, single-threaded core.
  • DragonflyDB — from scratch multi-threaded Redis clone with shard-per-thread design.
  • Skytable / KeyDB Pro — alternative takes; smaller ecosystems.
  • Memcached — simpler KV cache, no data structures or persistence.

FAQ

Q: Is KeyDB really a drop-in replacement? A: Yes — Redis 6/7-level protocol and RDB/AOF formats are compatible. Swap the binary and keep your clients. Q: Do I still need Redis Cluster? A: For sharding across many nodes, yes — KeyDB supports the same cluster protocol. Q: Active replication: how are conflicts resolved? A: Last-writer-wins per key, with timestamps on each write. Ideal for session/cache workloads. Q: Is KeyDB maintained? A: Yes — Snap bought KeyDB in 2022 and continues to release patches on GitHub.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产