repobenchmarks // cache architecture
COMPARISON
$ docker run -p 6379:6379 docker.dragonflydb.io/dragonflydb/dragonfly

Dragonfly vs Redis Architecture

A side-by-side technical evaluation of classic single-threaded Redis against Dragonfly's multi-threaded shared-nothing engine for demanding cache and session workloads.

Redis API: 100% Compatible Threading: Shared-Nothing Memory: Dashtable + VLL
Core Metrics
License: BSL 1.1 / Open
Snapshot: Zero-Fork B-Tree
Throughput: Multi-Core Scaling

For more than a decade, Redis has served as the default in-memory key-value store, cache, and message broker for web applications. However, Redis’s traditional single-threaded event loop design requires deploying Redis Cluster or multiple independent instances with complex proxies once traffic exceeds the capacity of a single CPU core. Dragonfly is a modern in-memory data store engineered in C++ that is API-compatible with Redis and Memcached, designed from the ground up for modern multi-core cloud servers.

Architectural Comparison: Single-Threaded vs Shared-Nothing

The fundamental distinction between Redis and Dragonfly lies in their CPU execution model and memory layout:

  • Redis: Uses a single main thread to execute commands, reading requests via non-blocking I/O multiplexing. While Redis 6 introduced multi-threaded I/O handling, actual data mutation remains strictly single-threaded to avoid lock contention. When a dataset outgrows a single CPU core's compute budget, engineers must partition keys across multiple Redis nodes.
  • Dragonfly: Uses a shared-nothing multi-threaded architecture based on user-space green threads (fibers). Memory is partitioned into logical shards assigned to specific hardware threads. Each thread operates independently on its partition without global mutex locks, allowing throughput to scale linearly with CPU core count on a single large cloud VM.
Memory & Threading Architecture Comparison
Dragonfly vs Redis Execution Architecture Shows how Redis uses a single event loop while Dragonfly distributes keys across independent thread-bound shards. Classic Redis (Single-Threaded) Single Event Loop & Key Mutation Engine Core 0 (100% CPU) Active Processing Cores 1..N Idle / Underutilized Dragonfly (Shared-Nothing Multi-Thread) Shard 0 Fiber Thread Core 0 Shard 1 Fiber Thread Core 1 Shard N Fiber Thread Core N

Memory Efficiency and Snapshot Mechanics

In standard Redis, creating an RDB snapshot relies on the Linux fork() system call. This triggers Copy-on-Write (CoW) page duplication. Under write-heavy conditions, this mechanism can double the operating system's resident memory requirements, leading to unexpected Out-of-Memory (OOM) kills if sufficient free RAM is not reserved.

Dragonfly avoids fork() entirely by utilizing a custom locking-free snapshotting algorithm based on an in-memory B-Tree structure. Snapshots run concurrently with ongoing mutations without duplicating memory pages, enabling operators to safely utilize up to 85–90% of host RAM without reserving a 50% buffer for CoW spikes.

Capability Redis (Standard) Dragonfly
Concurrency Model Single-threaded execution loop Multi-threaded shared-nothing (fibers)
Snapshot Strategy fork() with Copy-on-Write overhead Forkless snapshotting without memory spikes
Horizontal Scaling Redis Cluster (hash slot partitioning) Vertical scaling on large VMs + Cluster mode
Cache Eviction Engine Approximated LRU / LFU sampling Dashtable with Cache-friendly associative buckets
Software License RSALv2 / SSPLv1 (Post-March 2024) Business Source License (BSL 1.1)
⚠ Operational Caution: Multi-Key Transactions

Because Dragonfly shards data across thread-specific partitions, executing multi-key atomic transactions (MULTI/EXEC) or Lua scripts across keys residing on distinct shards requires a global coordinator fiber lock. While supported, issuing cross-shard transactions at high frequencies will reduce parallelism to single-threaded performance. Always design hash tags (e.g. {user:100}:profile) to pin related keys to the same shard.

Deployment Recommendation

For independent developers and small applications running on single-core or 2-core instances with modest throughput (< 50,000 requests/sec), standard Redis or Valkey remains rock-solid and universally understood. When scaling high-throughput workloads on large multi-core virtual machines (8+ vCPUs) with heavy caching requirements, Dragonfly eliminates the architectural complexity of running multi-node clusters while delivering significantly higher saturation ceilings per node.