Dragonfly: The C++ Data Store That Refuses to Be Single-Threaded

A deep dive into how Dragonfly uses fibers, shared-nothing concurrency, and API compatibility to turn one machine into a serious in-memory backend.

12 min read • View on GitHub • More from dragonflydb

A wide editorial illustration of a clockwork engine with one overloaded wheel on one side and a synchronized multi-gear machine on the other. It explains Dragonfly's core thesis: compatibility does not have to mean a single-threaded bottleneck.
Dragonfly treats vertical scale as an engine problem, not a clustering problem.
Key Takeaways

Dragonfly breaks the oldest rule in in-memory data stores: you do not have to choose between Redis-style compatibility and modern multi-core scaling. Its pitch is simple on paper and radical in practice. Keep the APIs people already know, then change the execution model under the hood.

That is why Dragonfly matters. It is not trying to be a prettier Redis clone. It is trying to make a single server feel like a much bigger cache tier without forcing teams into cluster complexity on day one.

The Redis rule Dragonfly breaks

Redis became the default because it was easy to adopt and predictable to operate. But its single-threaded core also fixed a ceiling in place. Dragonfly attacks that ceiling by using a modern C++ codebase and a shared-nothing design that can use all available cores on one machine.

DimensionRedisMemcachedDragonflyValkey
Concurrency modelSingle-threaded coreMulti-threaded, simpler cache pathShared-nothing, fiber-aware parallelismCompatibility-first fork
API surfaceRedis commandsMemcached protocolRedis and Memcached compatibleRedis compatible
Scaling betHorizontal or bigger boxesLean cache at scaleVertical scale on one machineContinuity with existing Redis users
Operational feelFamiliar and widely knownMinimalCompatibility plus modern engineFamiliar with governance shift
A close-up editorial illustration of a script moving through a row of fiber workstations inside a server chamber. It explains how Dragonfly uses pooled execution and user-space scheduling to keep other traffic flowing while work is in progress.
The point is not just more cores. It is less waiting around each core.

Why fibers matter more than threads

Dragonfly's internal language is fibers, not heavyweight OS threads. That matters because fibers let the server schedule a lot of work with far less overhead, which is exactly what an in-memory backend needs when many small requests arrive at once. The result is a system that tries to keep latency tight while still using the machine efficiently.

The unexpected part: Lua stops being a global bottleneck

This is Dragonfly's sharpest technical reveal. In Redis, Lua scripting is traditionally a server-wide event, which means one script can behave like a traffic jam. Dragonfly instead uses an InterpreterManager that pools lua_State instances, so scripts can be scheduled more like work items than like a single stop-the-world ritual.

The core idea is visible in src/core/interpreter.h. InterpreterManager::Get() and Return() allow interpreters to be borrowed and released, while ObjectExplorer acts like a visitor layer that translates values between Lua and Dragonfly objects. That keeps the scripting subsystem decoupled and makes parallel execution feel like part of the design, not a bolt-on hack.

Dragonfly is not Redis.

That quote matters because the architecture backs it up. Dragonfly is not just preserving a familiar command surface. It is changing what happens once the command arrives.

Compatibility without the usual tax

Compatibility is the on-ramp. If Dragonfly could not speak Redis and Memcached well enough for real workloads, the rest would be academic. But the product bet is bigger than translation. Dragonfly wants to preserve the API users already trust while changing the cost of serving it.

ProjectMain betWhat you getWhat you pay
RedisIncumbency and ecosystem gravityHuge familiarity and broad supportSingle-threaded ceiling and old tradeoffs
MemcachedSimplicityLean caching with low conceptual overheadFewer features and a narrower model
ValkeyContinuity after licensing disruptionRedis-compatible path with new governanceA transition story, not a new engine
DragonflyHardware efficiency on one machineRedis and Memcached compatibility with multi-core scalingA newer architecture that still has to prove itself in more deployments

That positioning explains why Dragonfly is interesting even to teams that are not actively fleeing Redis. It is a different answer to the same question: how much software do you really need before a single server can do the job?

What the build system reveals

The repository tells its own story. Dragonfly is C++20, not a prototype stitched together in a scripting language. It leans on sanitizers, thread-safety checks, fuzzing, GTest, and Kubernetes delivery tooling. That is not the posture of a hobby project chasing benchmark screenshots.

Core signals from the repo:
- C++20 as the baseline language standard
- Fiber-based concurrency in the internal runtime
- Sanitizers and thread-safety tooling in the build pipeline
- AFL++ fuzzing for crash and input hardening
- Helm charts and Kubernetes-oriented deployment assets

Dragonfly is committed to providing a powerful, self-hostable Community Edition, which is a source-available engine that is free to use forever.

Dragonfly Team, Project Team · Dragonfly 2025 in Review

That language is a useful counterweight to the performance narrative. Dragonfly wants to be fast, but it also wants to be operationally real.

Where Dragonfly fits in the post-Redis landscape

The post-Redis landscape is crowded, but the architectural bets are distinct. Valkey is continuity. Memcached is simplicity. Redis is still the default mental model for an in-memory store. Dragonfly is the outlier that says modern hardware should buy you more than a bigger cluster and more paging pages.

The deepest appeal is economic. If a single machine can absorb more load with lower tail latency, the business benefit is not just fewer servers. It is less operational spread, fewer moving parts, and a cache tier that can grow vertically before it has to become a distributed system.

The real thesis

Dragonfly's thesis is not that clusters are obsolete. It is that we often reach for them too early. By combining compatibility, fibers, and shared-nothing execution, Dragonfly tries to make one machine feel like a much better deployment primitive.

That is the part worth remembering. Dragonfly does not merely run Redis commands. It challenges the assumption that compatibility must come with a single-threaded tax.