Skip to content

Dragonfly — a modern Redis-compatible in-memory store

Dragonfly as a Redis/Memcached protocol drop-in with vertical scaling, snapshot consistency, and a different memory model — where it fits and what to test.

Dragonfly is a Redis- and Memcached-protocol-compatible in-memory store designed to scale vertically across many cores on a single host. Where upstream Redis runs one command thread per instance, Dragonfly partitions keys across shards owned by individual threads and processes them lockfree. For workloads bottlenecked on Redis’s single-thread ceiling, swapping to Dragonfly can be a one-binary change that lifts throughput by an order of magnitude. This article is the operational picture we give clients evaluating it.

How to verify

Check whether the runtime is upstream Redis, KeyDB, or Dragonfly, and confirm the protocol version it speaks.

redis-cli INFO server | grep -iE 'version|os|redis_mode|process_id'
redis-cli INFO memory | grep -iE 'used_memory|maxmemory'
redis-cli DEBUG OBJECT testkey 2>&1 | head
redis-cli COMMAND COUNT

Dragonfly’s INFO server reports dragonfly_version (not redis_version) and a small set of Redis-specific commands report differently — DEBUG OBJECT is a notable absence.

What’s happening

Upstream Redis processes commands on a single thread. CPU-bound workloads (lots of small GETs, lots of pipelined commands) cap out at ~150k-300k ops/sec per instance on modern hardware. The standard mitigation is Redis Cluster — shard the keyspace across instances on different cores. Dragonfly takes a different approach: one process, many threads, each thread owning a slice of the keyspace internally. The application connects to a single endpoint and the threading is invisible.

Dragonfly’s snapshot model is also different. Upstream Redis’s BGSAVE forks the process — for large memory sets, the fork copy-on-write cost spikes RSS at exactly the wrong moment. Dragonfly’s snapshot is point-in-time consistent and incremental, without the fork.

The trade-off is feature coverage. Dragonfly implements the Redis API faithfully for the common commands (strings, hashes, lists, sets, sorted sets, streams) and the Memcached text protocol. It implements MULTI/EXEC transactions and Lua scripting. It does not implement the full Redis Cluster protocol (no CLUSTER commands), some module-specific commands, or DEBUG OBJECT. If your code relies on any of those, test before you swap.

The decision

  1. Pick Dragonfly when: you have a single hot Redis instance saturating one core, you want to consolidate sharded Redis Cluster nodes onto fewer larger boxes, or you want simpler operations (no Sentinel, no cluster topology). Vertical scaling on a 32-core box is its strong suit.

  2. Stay on upstream Redis when: you use Redis Cluster slots actively (some clients route by slot), you depend on Redis modules (RedisJSON, RediSearch, RedisTimeSeries — Dragonfly has its own JSON support but it is not the same module), or your operations team already runs Redis competently and the cost of swapping outweighs the throughput win.

  3. Install Dragonfly. Available as a deb or as a container; pin the major version explicitly.

    wget https://github.com/dragonflydb/dragonfly/releases/download/v1.21.0/dragonfly-x86_64.tar.gz
    tar xzf dragonfly-x86_64.tar.gz
    install -m 0755 dragonfly-x86_64 /usr/local/bin/dragonfly
    useradd --system --shell /sbin/nologin dragonfly
    mkdir -p /var/lib/dragonfly && chown dragonfly:dragonfly /var/lib/dragonfly
  4. Run with a systemd unit. Memory limit and thread count are the two tunables that matter most.

    # /etc/systemd/system/dragonfly.service
    [Unit]
    Description=Dragonfly in-memory store
    After=network-online.target
    
    [Service]
    User=dragonfly
    ExecStart=/usr/local/bin/dragonfly \
      --bind 0.0.0.0 \
      --port 6379 \
      --maxmemory=8gb \
      --proactor_threads=8 \
      --dir /var/lib/dragonfly \
      --snapshot_cron="*/30 * * * *"
    Restart=on-failure
    LimitNOFILE=65536
    
    [Install]
    WantedBy=multi-user.target
  5. Test client compatibility. Run the application’s full test suite against Dragonfly before switching production traffic. The ones that bite are usually around INFO parsing, CLUSTER NODES (returns empty on Dragonfly), and any code that calls DEBUG.

    redis-cli -h dragonfly.internal -p 6379 PING
    redis-cli -h dragonfly.internal -p 6379 INFO server | head
    redis-cli -h dragonfly.internal -p 6379 CLIENT NO-EVICT ON
    redis-benchmark -h dragonfly.internal -p 6379 -t set,get -n 100000 -c 50

Common pitfalls

  • Sizing proactor_threads to “all the cores” — leave one or two for the kernel and observability daemons.
  • Treating Dragonfly’s persistence as a 1:1 replacement for Redis AOF — it is a periodic snapshot, not a write-ahead log. If you need point-in-time durability per write, Dragonfly is not the right answer.
  • Migrating with redis-cli --rdb — Dragonfly reads RDB format on import but the export format is its own; round-trip migrations require care.
  • Expecting CLIENT LIST output to look like Redis’s — it does not, and dashboards that parse it break.
  • Skipping the maxmemory flag — Dragonfly will happily eat the host’s RAM if you let it.

We deploy Dragonfly for clients hitting the single-core Redis ceiling who do not want to operate a Redis Cluster. The protocol compatibility makes the rollback cheap — point traffic back at Redis if the swap reveals an incompatibility. Stack Harbor’s managed operations approach is to run the test suite under both for a sprint, then make the call with data on the table.