Skip to content
STACK IT FAST

Dragonfly

Curated OSSClassicMulti-Threaded In-Memory Key-Value Store20+ People

Audited from github.com/dragonflydb/dragonfly

Dragonfly is an in-memory data store implementing the Redis and Memcached wire protocols in C++, built on a custom thread-per-core fiber runtime (Helio) with its own hash-table structures, RDB-compatible snapshotting, and a built-in HNSW vector index.

Language
C++
Hosting
Docker
Running for
2 years
Team
20+ People

Why this architecture

A fiber-based, shared-nothing execution model (one thread and one keyspace shard per core) lets Dragonfly scale vertically across cores, which single-threaded Redis cannot do without external sharding, while staying protocol-compatible so existing clients need no changes.

Tech stack by layer

7 technologies · audited Sep 17, 2026
Backend & APIs
  • C++The entire server (src/server, src/core, src/facade) is written in C++, built with CMake and Ninja.
  • HelioDragonfly's in-house fiber-based async I/O and event-loop library that the server's thread-per-core execution model is built on.
  • src/facadeImplements the Redis and Memcached wire protocols so existing clients work against Dragonfly unmodified.
  • src/redisVendored/adapted Redis-compatible components (command definitions, RDB helpers) reused inside the Dragonfly server.
Data & Persistence
  • In-memory dashtable/dense_setDragonfly's custom hash-table structures (docs/dashtable.md, dense_set.md) back key-value storage instead of Redis's own structures.
  • RDB-compatible snapshottingBackground save produces Redis RDB-format snapshots for persistence and replication bootstrapping.
  • Async tieringOptional tiering of colder data out to disk/SSD to extend effective memory capacity beyond RAM.
  • Vector search (HNSW)HNSW-based vector index with its own replication protocol for approximate nearest-neighbor search.
Infrastructure & Deploy
  • CMake + NinjaPrimary build system; the Makefile wraps a cmake configure step and a ninja dragonfly build.
  • DockerContainer images built from contrib/docker for release and dev variants.
  • Helm chartcontrib/charts/dragonfly packages Dragonfly for Kubernetes deployment.
Tooling, Testing & Ops
  • pytest integration suitePython test suite (tests/dragonfly) exercises the server via redis-py, valkey, and fakeredis clients.
  • libFuzzer harnessDedicated fuzzing targets and crash-triage scripts under fuzz/ for the RESP/Memcached parsers.
  • GitHub ActionsCI covers unit/regression/heavy/epoll-v2 test matrices, fuzzing, benchmarking, and multi-arch Docker releases.

Dragonfly architecture diagram

Open SVG
Dragonfly architecture diagramRedis / Memcached clients → Protocol facade (commands); Protocol facade → Shard threads (dispatch); Shard threads → Dashtable (read / write); Shard threads → Vector search (index); Shard threads → Snapshots (background save); Shard threads → Tiered storage (cold values); Shard threads → Replicas (replicate)CLIENTSSERVICESWORKERS & JOBSDATA & STORAGEEXTERNALRedis / Memcached clientsunmodifiedProtocol facadeRESP · MemcachedShard threadsHelio fibersVector searchHNSWDashtablein-memory keysSnapshotsRDB formatTiered storageSSD (optional)Replicasreplicationindexcommandsdispatchread / writebackground savecold valuesreplicate
How the main components of Dragonfly connect, drawn from the audited repository.
Diagram as text
  • Redis / Memcached clients (unmodified) → Protocol facade (RESP · Memcached): commands
  • Protocol facade (RESP · Memcached) → Shard threads (Helio fibers): dispatch
  • Shard threads (Helio fibers) → Dashtable (in-memory keys): read / write
  • Shard threads (Helio fibers) → Vector search (HNSW): index
  • Shard threads (Helio fibers) → Snapshots (RDB format): background save
  • Shard threads (Helio fibers) → Tiered storage (SSD (optional)): cold values
  • Shard threads (Helio fibers) → Replicas (replication): replicate

Key architectural decisions

6 decisions
  1. 01

    A custom fiber runtime (Helio) replaces an event-loop library like libuv

    The server is built around helio, an in-repo/vendored C++ fiber and async-I/O library, rather than libuv or Boost.Asio directly, giving Dragonfly a thread-per-core execution model where each core runs its own event loop and shard of the keyspace.

  2. 02

    Redis and Memcached compatibility is a protocol-level facade, not a fork

    src/facade implements the RESP and Memcached wire protocols against Dragonfly's own data structures and execution engine in src/core and src/server, so existing Redis/Memcached clients work unmodified without the server being a source fork of either.

  3. 03

    Persistence targets the RDB format for drop-in compatibility

    docs/rdbsave.md documents background snapshotting into the Redis RDB format rather than a Dragonfly-specific format, so existing RDB tooling and Redis migration paths keep working.

  4. 04

    Custom hash-table structures replace Redis's dict/ziplist internals

    docs/dashtable.md and docs/dense_set.md describe purpose-built data structures for the keyspace, distinct from Redis's own dict implementation, chosen to support the multi-threaded, shard-per-core design.

  5. 05

    Vector search ships as a built-in index, not a separate module

    docs/hnsw-index-replication.md and docs/hnsw-replication-serialize.excalidraw describe an HNSW vector index integrated into the core server with its own replication/serialization path, rather than being implemented as a loadable Redis module.

  6. 06

    Kubernetes deployment is a first-party Helm chart

    contrib/charts/dragonfly is maintained in-repo with its own Go module (used for chart testing via terratest), rather than leaving Kubernetes packaging entirely to the community.

How Dragonfly is built

How Dragonfly is structured

Dragonfly is a C++ project built with CMake (src/CMakeLists.txt) and Ninja, wrapped by a top-level Makefile (make configure, make build, make release). The server implementation lives under src/: src/core holds core data structures (dashtable, dense set), src/server implements command handling and the transaction/coordination layer, src/facade implements the Redis (RESP) and Memcached wire protocols, and src/redis carries adapted Redis-derived components. helio, vendored at the repo root, is Dragonfly's fiber-based async I/O runtime. Supporting code includes tools/ (benchmarking, cluster management, replay, defrag tooling in Python and Go), fuzz/ (libFuzzer harnesses), tests/dragonfly (Python integration tests), and contrib/ (Docker build files and a Kubernetes Helm chart).

Backend & APIs

There is no separate "backend service" layer — the C++ binary built from src/server is the whole product, exposing the Redis and Memcached protocols directly via src/facade. docs/df-share-nothing.md documents the shared-nothing architecture: each CPU core runs its own event loop (via helio) and owns a shard of the keyspace, so most operations avoid cross-core locking. docs/transaction.md and docs/coordinator.excalidraw describe how multi-key transactions coordinate across shards when a command touches keys owned by more than one core. Cluster mode (docs/cluster-mode.md, docs/cluster-topology.md, docs/cluster-slot-migration.md) adds Redis Cluster-style slot ownership and migration on top of the same per-node architecture.

Data & persistence

Keys are stored in custom data structures rather than a reused Redis dict: docs/dashtable.md and docs/dense_set.md describe the hash-table designs built for the multi-threaded engine, and docs/zero_copy_get.md documents a zero-copy read path. Persistence targets the Redis RDB format (docs/rdbsave.md, docs/memory_bgsave.tsv) so existing snapshot tooling and migration paths from Redis continue to work. docs/async-tiering.md describes an optional tier that moves colder data to disk/SSD to extend effective capacity past available RAM. Dragonfly also ships a built-in vector index: docs/hnsw-index-replication.md and the accompanying serialization diagrams describe an HNSW-based approximate nearest-neighbor index with its own replication support, integrated into the core server rather than loaded as an external module. Replication itself is documented in docs/replication.md.

Build, test & deploy

The canonical build path is make configure (CMake with Ninja generator, static Boost/OpenSSL linking for release builds) followed by make build (ninja dfly_bench dragonfly). .circleci/config.yml and a large .github/workflows set (ci.yml, regression-tests.yml, heavy-tests.yml, epoll-regression-tests.yml, ioloop-v2-regtests.yml, repeat-tests.yml) run the C++ unit tests and the Python integration suite in tests/dragonfly (via pyproject.toml's test dependency group: pytest, redis, valkey, fakeredis, pymemcache). fuzz-pr.yml and fuzz-long.yml run the libFuzzer harnesses in fuzz/ against the RESP and Memcached parsers. mastodon-ruby-tests.yml and bullmq-tests.yml run real third-party client/library test suites against Dragonfly to catch protocol compatibility regressions. Release artifacts are built and published by release.yml, docker-release2.yml, and daily-builds.yml.

Self-hosting notes

contrib/docker contains the Dockerfiles used to build published container images, and docker-release2.yml/docker-dev-release.yml publish multi-arch images to a registry. For Kubernetes, contrib/charts/dragonfly is a first-party Helm chart, tested with terratest (its own go.mod). Running from source requires the CMake/Ninja toolchain described above; docs/build-from-source.md covers per-distro setup, and .devcontainer/ provides prebuilt dev containers for several distros (Alpine, Fedora, Ubuntu 20/22/24) to avoid needing to install the C++ toolchain manually.

What to copy (and what not to)

The protocol-facade pattern — implementing a widely-adopted wire protocol (src/facade) as a thin layer over an internally optimized engine, rather than forking the reference implementation — is a strong way to get compatibility and an existing client ecosystem for free while keeping full control of internals. A thread-per-core, shared-nothing execution model is worth copying for workloads that are CPU-bound and can partition cleanly by key, but it adds real complexity around cross-shard transactions (docs/transaction.md) that a simpler single-threaded or thread-pool design would avoid. Building a custom fiber runtime (helio) instead of using an off-the-shelf async library is a decision that only pays off at Dragonfly's performance ceiling — most applications are better served by an existing event-loop library than maintaining one in-house.

Sources & repo audit

Audited
Sep 17, 2026
Commit
4776811
License
NOASSERTION

Independent analysis of repository at github.com/dragonflydb/dragonfly. Spotted an inaccuracy? Use the claim form to request a correction.

Show this stack on your README or website
Tech stack of Dragonfly
[![Tech stack of Dragonfly on STACK IT FAST](https://stackitfast.com/badge/dragonfly.svg)](https://stackitfast.com/project/dragonfly)

Paste it into your README. It shows your current stack and links to this page.

Use this stack

Scaffold it with your agent

Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Dragonfly's architecture.

  1. 1Copy the promptThe full markdown spec, with every layer and decision.
  2. 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
  3. 3Paste and scaffoldUse it as the first instruction; review before you ship.
use-this-stack.md · 60 lines · 7.7 KB
# MISSION: Scaffold "Dragonfly" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **Dragonfly**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Dragonfly
- **What It Does**: Dragonfly is an in-memory data store implementing the Redis and Memcached wire protocols in C++, built on a custom thread-per-core fiber runtime (Helio) with its own hash-table structures, RDB-compatible snapshotting, and a built-in HNSW vector index.
- **Domain & Category**: Multi-Threaded In-Memory Key-Value Store
- **Production Scale**: 20+ People
- **Development Mode**: CLASSIC
- **Architectural Rationale**: A fiber-based, shared-nothing execution model (one thread and one keyspace shard per core) lets Dragonfly scale vertically across cores, which single-threaded Redis cannot do without external sharding, while staying protocol-compatible so existing clients need no changes.
- **Live Website Reference**: https://dragonflydb.io
- **Source Repository**: https://github.com/dragonflydb/dragonfly
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: C++, CMake, Python, Go, Docker, Redis, Memcached protocol
- **Primary Language(s)**: C++, Python, C
- **License of the reference repo**: NOASSERTION
- **Backend & APIs**: C++ — The entire server (src/server, src/core, src/facade) is written in C++, built with CMake and Ninja.; Helio — Dragonfly's in-house fiber-based async I/O and event-loop library that the server's thread-per-core execution model is built on.; src/facade — Implements the Redis and Memcached wire protocols so existing clients work against Dragonfly unmodified.; src/redis — Vendored/adapted Redis-compatible components (command definitions, RDB helpers) reused inside the Dragonfly server.
- **Data & persistence**: In-memory dashtable/dense_set — Dragonfly's custom hash-table structures (docs/dashtable.md, dense_set.md) back key-value storage instead of Redis's own structures.; RDB-compatible snapshotting — Background save produces Redis RDB-format snapshots for persistence and replication bootstrapping.; Async tiering — Optional tiering of colder data out to disk/SSD to extend effective memory capacity beyond RAM.; Vector search (HNSW) — HNSW-based vector index with its own replication protocol for approximate nearest-neighbor search.
- **Infrastructure & deploy**: CMake + Ninja — Primary build system; the Makefile wraps a cmake configure step and a ninja dragonfly build.; Docker — Container images built from contrib/docker for release and dev variants.; Helm chart — contrib/charts/dragonfly packages Dragonfly for Kubernetes deployment.
- **Tooling, testing & ops**: pytest integration suite — Python test suite (tests/dragonfly) exercises the server via redis-py, valkey, and fakeredis clients.; libFuzzer harness — Dedicated fuzzing targets and crash-triage scripts under fuzz/ for the RESP/Memcached parsers.; GitHub Actions — CI covers unit/regression/heavy/epoll-v2 test matrices, fuzzing, benchmarking, and multi-arch Docker releases.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/dragonflydb/dragonfly @ 4776811)
1. **A custom fiber runtime (Helio) replaces an event-loop library like libuv**: The server is built around helio, an in-repo/vendored C++ fiber and async-I/O library, rather than libuv or Boost.Asio directly, giving Dragonfly a thread-per-core execution model where each core runs its own event loop and shard of the keyspace.
2. **Redis and Memcached compatibility is a protocol-level facade, not a fork**: src/facade implements the RESP and Memcached wire protocols against Dragonfly's own data structures and execution engine in src/core and src/server, so existing Redis/Memcached clients work unmodified without the server being a source fork of either.
3. **Persistence targets the RDB format for drop-in compatibility**: docs/rdbsave.md documents background snapshotting into the Redis RDB format rather than a Dragonfly-specific format, so existing RDB tooling and Redis migration paths keep working.
4. **Custom hash-table structures replace Redis's dict/ziplist internals**: docs/dashtable.md and docs/dense_set.md describe purpose-built data structures for the keyspace, distinct from Redis's own dict implementation, chosen to support the multi-threaded, shard-per-core design.
5. **Vector search ships as a built-in index, not a separate module**: docs/hnsw-index-replication.md and docs/hnsw-replication-serialize.excalidraw describe an HNSW vector index integrated into the core server with its own replication/serialization path, rather than being implemented as a loadable Redis module.
6. **Kubernetes deployment is a first-party Helm chart**: contrib/charts/dragonfly is maintained in-repo with its own Go module (used for chart testing via terratest), rather than leaving Kubernetes packaging entirely to the community.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
   - Structure as a Turborepo monorepo with strict package boundaries:
     - `apps/web`: Application UI, routing, layouts, and server endpoints.
     - `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
     - `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
     - `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
   - Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
   - Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
   - Isolate interactive UI state to leaf components. Keep core pages lightweight and performant.
4. **Design System & Aesthetics**:
   - Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
   - Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
   - Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
   - Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer (In-memory dashtable/dense_set, RDB-compatible snapshotting, Async tiering, Vector search (HNSW)): client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.
Scaffolded something with this prompt?
Would you pick this stack for a multi-threaded in-memory key-value store project?

Frequently asked about Dragonfly

What is Dragonfly built with?

Dragonfly is written in C++ (src/server, src/core, src/facade), built with CMake and Ninja, and runs on Helio, an in-house fiber-based async I/O library that gives it a thread-per-core, shared-nothing execution model. Go and Python are used for cluster/replay tooling and the integration test suite, not the server itself.

Does Dragonfly need a backend?

Dragonfly is the backend: it is an in-memory data store, not a client library, meant to be run as a standalone server that Redis- or Memcached-protocol clients connect to.

Can I self-host Dragonfly?

Yes. It ships as a single binary built via make configure && make build, as Docker images from contrib/docker, and as a Kubernetes Helm chart under contrib/charts/dragonfly for cluster deployment.

Is Dragonfly a drop-in replacement for Redis?

It targets protocol compatibility: src/facade implements the RESP (Redis) and Memcached wire protocols, and docs/rdbsave.md documents RDB-format snapshotting, so existing clients and some tooling can point at Dragonfly without changing application code, per the differences documented in docs/differences.md.

One email a month: new deep dives and stack trends

New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.

use-this-stack.md