Dragonfly on a VPS: Multi-Threaded In-Memory Database with 25x Better Throughput Than Redis
Dragonfly is a modern, multi-threaded in-memory data store that is fully compatible with the Redis and Memcached APIs — but processes requests 25× faster than Redis on the same hardware by using all available CPU cores. Redis is single-threaded (one core handles all commands); Dragonfly uses a shared-nothing architecture that scales linearly with vCPU count. For high-throughput applications hitting Redis performance limits, Dragonfly is a drop-in replacement requiring zero application code changes.
Dragonfly vs Redis vs Valkey
| Factor | Dragonfly | Valkey | Redis |
|---|---|---|---|
| Threading model | Multi-threaded (all cores) | Single-threaded (like Redis) | Single-threaded |
| Throughput | 25× Redis on 16+ cores | Similar to Redis | Baseline |
| Memory efficiency | 30% less RAM than Redis | Similar to Redis | Baseline |
| License | BSL (open for self-hosting) | BSD | SSPL |
| API compatibility | Redis + Memcached | Redis | Redis |
| Best for | High concurrency workloads | General Redis replacement | Legacy deployments |
When Dragonfly Wins Over Valkey/Redis
Dragonfly’s advantage scales with CPU cores and concurrency. On a 2-core VPS with low concurrency, the difference is minimal. On a 16-core VPS handling thousands of concurrent connections, Dragonfly outperforms Redis by 10–25×. Choose Dragonfly when your Redis CPU usage is consistently high or when you need to handle tens of thousands of operations per second.
Step 1: Docker Compose Setup
<code">mkdir -p /opt/dragonfly && cd /opt/dragonfly nano docker-compose.yml
<code">version: '3.8'
services:
dragonfly:
image: 'docker.dragonflydb.io/dragonflydb/dragonfly:latest'
container_name: dragonfly
restart: always
ports:
- "127.0.0.1:6379:6379"
ulimits:
memlock: -1 # Required for Dragonfly's memory management
command:
- "--requirepass=${DRAGONFLY_PASSWORD}"
- "--maxmemory=1gb"
- "--maxmemory-policy=allkeys-lru"
- "--save_schedule=:00" # Snapshot every hour at :00
- "--dbfilename=dragonfly.dfs"
- "--hz=100"
- "--io-threads=4" # Set to vCPU count - 1
volumes:
- dragonfly_data:/data
volumes:
dragonfly_data:
<code">echo "DRAGONFLY_PASSWORD=StrongDragonflyPassword!" > .env chmod 600 .env docker compose up -d docker compose logs -f dragonfly # Verify connection (uses standard redis-cli) redis-cli -h localhost -p 6379 -a StrongDragonflyPassword! PING # PONG
Step 2: Benchmark vs Redis
<code"># Install redis-benchmark
sudo apt install -y redis-tools
# Benchmark Dragonfly:
redis-benchmark \
-h localhost -p 6379 \
-a StrongDragonflyPassword! \
-c 100 \ # 100 concurrent connections
-n 1000000 \ # 1 million operations
-t SET,GET,LPUSH,LPOP \
--threads 4 # Use multiple benchmark threads
# Compare output:
# Redis (single-threaded): ~100,000 ops/sec
# Dragonfly (4 threads): ~800,000 ops/sec (8× faster on 4 cores)
# Dragonfly (16 threads): ~2,500,000 ops/sec (25× faster on 16 cores)
Step 3: Migrate from Redis (Zero Downtime)
<code"># Option A: Live migration (best for production) # 1. Start Dragonfly alongside Redis (different port) # 2. Use REPLICAOF to sync Dragonfly from Redis: redis-cli -p 6380 -a DragonflyPass REPLICAOF localhost 6379 # Wait for full sync (monitor with INFO replication) # 3. Update application connection string to port 6380 # 4. Promote Dragonfly to primary: redis-cli -p 6380 -a DragonflyPass REPLICAOF NO ONE # 5. Stop Redis # Option B: Simple migration (brief downtime) # 1. Stop application # 2. Dump Redis: redis-cli -a OLD_PASS --rdb /tmp/dump.rdb BGSAVE # 3. Stop Redis # 4. Start Dragonfly (reads dump.rdb natively) # 5. Start application pointing to Dragonfly
Step 4: Application Integration (Zero Changes)
<code">// Node.js — no changes needed
import { createClient } from 'redis';
const client = createClient({
socket: { host: 'localhost', port: 6379 },
password: 'StrongDragonflyPassword!',
// Everything else stays identical
});
<code">import redis
# Python — no changes needed
r = redis.Redis(
host='localhost',
port=6379,
password='StrongDragonflyPassword!',
decode_responses=True,
)
# All Redis commands work identically:
r.set('key', 'value', ex=300)
r.lpush('queue', 'job1', 'job2')
r.hset('user:1', mapping={'name': 'Alice', 'email': 'alice@example.com'})
Step 5: Configuration Tuning
<code"># Key Dragonfly configuration options: # (passed as command-line flags in docker-compose command:) # Threading --io-threads=N # Set to vCPU count (auto-detects if omitted) # Memory --maxmemory=2gb # Set memory limit --maxmemory-policy=allkeys-lru # Eviction policy # Persistence --save_schedule=:00 # Snapshot every hour at minute :00 --save_schedule=*/30 # Snapshot every 30 minutes --dbfilename=dragonfly.dfs --no_save # Disable snapshots (pure cache) # Append-Only File (better durability than snapshots) --aof-rewrite-min-size=256mb --appendsave # Enable AOF # Network --bind=127.0.0.1 # Listen only on localhost --port=6379
Step 6: Monitor Dragonfly
<code"># Dragonfly exposes a Redis-compatible INFO command redis-cli -a StrongDragonflyPassword! INFO # Key metrics to watch: # instantaneous_ops_per_sec — current throughput # used_memory_human — memory usage # connected_clients — active connections # keyspace_hits/misses — cache effectiveness # Dragonfly also exposes Prometheus metrics: curl http://localhost:6379/metrics # If enabled with --prometheus_enable # Thread utilization redis-cli -a StrongDragonflyPassword! INFO server | grep -E "io_threads|version"
Getting Started
Dragonfly’s advantage over Redis grows with your VPS core count. On a 4-core Ubuntu VPS at VPS.DO, expect 3–5× Redis throughput; on an 8-core VPS, 8–12×. For most applications on smaller VPS plans, Valkey (Redis-compatible, BSD licensed) provides equivalent throughput. Dragonfly shines on multi-core VPS instances handling high-concurrency API traffic, session stores for large user bases, or job queues processing thousands of tasks per second.
Conclusion
Dragonfly provides Redis-compatible in-memory data storage with multi-threaded performance that scales with CPU cores — 25× Redis throughput on 16-core hardware. The shared-nothing threading architecture eliminates the single-threaded bottleneck that limits Redis at high concurrency. Application migration is zero-code: point your Redis client at Dragonfly, set the password, and existing applications work unchanged. For high-throughput VPS workloads where Redis CPU becomes a bottleneck, Dragonfly is the highest-performance drop-in replacement available.