What DragonflyDB Does
- Redis compatible — RESP protocol, most Redis commands
- Memcached compatible — text and binary protocols
- Multi-threaded — shared-nothing, scales across all cores
- Memory efficient — novel data structures use ~40% less RAM
- Snapshots — RDB-compatible persistence
- Replication — Redis-compatible replication protocol
- Pub/Sub — full pub/sub support
- Lua scripting — Redis Lua scripts work unchanged
- Cluster mode — emulated cluster for Redis cluster clients
- ACL — Redis-compatible ACL system
Architecture
Shared-nothing multi-threaded design: each thread owns a slice of the keyspace. No global locks. Novel dashtable data structure replaces Redis dict for lower memory overhead and better cache locality. IO is handled via io_uring (Linux) for minimal syscall overhead.
Self-Hosting
version: "3"
services:
dragonfly:
image: docker.dragonflydb.io/dragonflydb/dragonfly
ports: ["6379:6379"]
volumes:
- dragonfly-data:/data
ulimits:
memlock: -1
volumes:
dragonfly-data:Key Features
- Redis + Memcached wire compatibility
- 25x throughput vs Redis (single instance)
- 40% less memory usage
- Multi-threaded (shared-nothing)
- RDB snapshot persistence
- Replication
- Lua scripting
- ACL security
- io_uring (Linux)
- Drop-in replacement
Comparison
| Store | Threads | Protocol | Memory |
|---|---|---|---|
| DragonflyDB | Multi (shared-nothing) | Redis + Memcached | Best |
| Redis | Single | RESP | Good |
| Valkey | Single | RESP | Good (Redis fork) |
| KeyDB | Multi (shared) | RESP | Good |
| Garnet (MS) | Multi | RESP | Good |
常见问题 FAQ
Q: 能直接替换 Redis 吗? A: 大部分场景可以。RESP 协议兼容,大部分 Redis 命令支持。少数高级 Redis 功能(Redis Modules、某些 cluster 边缘行为)不支持。
Q: BSL 限制? A: 4 年后自动转 Apache 2.0。期间自用完全 OK,只是不能做托管 Dragonfly 服务与官方竞争。
Q: 为什么这么快? A: 多线程 + 无锁 shared-nothing + io_uring + 紧凑数据结构(dashtable)。单机可以跑满一台 96 核服务器。
来源与致谢 Sources
- Docs: https://www.dragonflydb.io/docs
- GitHub: https://github.com/dragonflydb/dragonfly
- License: BSL 1.1