Deploy DragonflyDB on a VPS
A modern, multi-threaded Redis replacement with up to 25x throughput. Full production setup with security, persistence, and kernel tuning.
What Is DragonflyDB?
DragonflyDB is an open-source, drop-in replacement for Redis and Memcached. It uses a shared-nothing architecture that fully saturates modern multi-core CPUs without the single-threaded bottleneck that limits Redis. It speaks the Redis Serialization Protocol (RESP), so existing clients, libraries, and tooling work without changes.
Key advantages on a VPS:
- Multi-threaded — puts all your vCPUs to work instead of one
- Lower memory overhead than Redis for the same dataset
- Built-in Memcached protocol support
- Native snapshot and AOF persistence
- Redis-compatible — swap the connection string, nothing else changes
Requirements
| Component | Minimum | Recommended |
|---|---|---|
| OS | Ubuntu 20.04 | Ubuntu 22.04 LTS |
| Kernel | 4.19 | 5.10+ |
| RAM | 1 GB | 4 GB+ |
| CPU | 1 vCPU | 2+ vCPUs |
| Disk | 10 GB | 20 GB+ (for snapshots) |
A RamNode NVMe VPS running Ubuntu 22.04 is an ideal fit. Even entry-level plans give you enough headroom to run DragonflyDB alongside your application stack.
Update Your System
sudo apt update && sudo apt upgrade -yReboot if a kernel update was applied:
sudo rebootInstall DragonflyDB via APT
DragonflyDB maintains an official APT repository for Debian/Ubuntu.
sudo curl -Lo /usr/share/keyrings/dragonfly-keyring.public \
https://packages.dragonflydb.io/pgp-key.publicsudo curl -Lo /etc/apt/sources.list.d/dragonfly.sources \
https://packages.dragonflydb.io/dragonfly.sourcessudo apt update && sudo apt install -y dragonflyConfigure DragonflyDB
Create a configuration file with production-ready settings:
sudo mkdir -p /etc/dragonfly
sudo nano /etc/dragonfly/dragonfly.conf--bind=127.0.0.1
--port=6379
--requirepass=YOUR_STRONG_PASSWORD_HERE
--maxmemory=512mb
--dbfilename=dump.rdb
--dir=/var/lib/dragonfly
--snapshot_cron=*/30 * * * *
--logtostderr
--loglevel=info- •
--bind=127.0.0.1— binds only to localhost; don't expose to0.0.0.0without strict firewall rules - •
--requirepass— always set a password on internet-facing servers - •
--maxmemory— set to ~60-70% of available RAM for OS headroom - •
--snapshot_cron— RDB snapshots every 30 minutes
Create the data directory:
sudo mkdir -p /var/lib/dragonfly
sudo chown dragonfly:dragonfly /var/lib/dragonflyConfigure the systemd Service
The APT package installs a default systemd unit. Point it at your config file with a drop-in override:
sudo systemctl edit dragonflyAdd the following:
[Service]
ExecStart=
ExecStart=/usr/bin/dragonfly --flagfile=/etc/dragonfly/dragonfly.confThe first empty ExecStart= clears the default command before setting the new one.
Enable and Start the Service
sudo systemctl daemon-reload
sudo systemctl enable --now dragonflyCheck that it started cleanly:
sudo systemctl status dragonflyIf not running, check logs:
sudo journalctl -u dragonfly -n 50 --no-pagerVerify Connectivity
Install the Redis CLI if you don't already have it:
sudo apt install -y redis-toolsConnect and authenticate:
redis-cli -p 6379 -a YOUR_STRONG_PASSWORD_HERE PINGA PONG response confirms DragonflyDB is running. Run an info check:
redis-cli -p 6379 -a YOUR_STRONG_PASSWORD_HERE INFO serverYou'll see dragonfly_version in the output confirming you're talking to DragonflyDB.
Firewall Configuration
If your app runs on the same VPS, since DragonflyDB is bound to 127.0.0.1, no additional rule is needed:
sudo ufw allow ssh
sudo ufw enableIf your app runs on a separate VPS in the same datacenter, allow access from that private IP only:
sudo ufw allow from YOUR_APP_SERVER_IP to any port 6379Then update your DragonflyDB bind address to include the private network interface and restart the service.
Kernel Tuning (Optional but Recommended)
Disable transparent huge pages (reduces latency spikes):
echo never | sudo tee /sys/kernel/mm/transparent_hugepage/enabledIncrease max open files:
dragonfly soft nofile 65536
dragonfly hard nofile 65536Adjust overcommit memory:
echo 1 | sudo tee /proc/sys/vm/overcommit_memory
echo "vm.overcommit_memory = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -pSnapshot and Persistence
RDB snapshots are already configured via --snapshot_cron in your config. Snapshots are written to /var/lib/dragonfly/dump.rdb.
To enable AOF for stronger durability, add to your config:
--aof_rewrite_min_size=128mbsudo systemctl restart dragonflyFor most VPS use cases — session storage, caching, rate limiting — RDB snapshots every 30 minutes are the right balance. Enable AOF if you're using DragonflyDB as a primary data store.
Connect Your Application
Since DragonflyDB speaks RESP natively, any Redis client works. Update your connection string to 127.0.0.1:6379 with your password.
Node.js (ioredis):
const Redis = require('ioredis');
const client = new Redis({
host: '127.0.0.1',
port: 6379,
password: 'YOUR_STRONG_PASSWORD_HERE',
});Python (redis-py):
import redis
client = redis.Redis(host='127.0.0.1', port=6379, password='YOUR_STRONG_PASSWORD_HERE')PHP (Predis):
$client = new Predis\Client([
'host' => '127.0.0.1',
'port' => 6379,
'password' => 'YOUR_STRONG_PASSWORD_HERE',
]);No code changes beyond the connection details are needed.
Managing DragonflyDB
| Task | Command |
|---|---|
| Start | sudo systemctl start dragonfly |
| Stop | sudo systemctl stop dragonfly |
| Restart | sudo systemctl restart dragonfly |
| View logs | sudo journalctl -u dragonfly -f |
| Check status | sudo systemctl status dragonfly |
| Manual save | redis-cli -a PASSWORD BGSAVE |
| Memory usage | redis-cli -a PASSWORD INFO memory |
Upgrading DragonflyDB
Since you installed via APT, upgrades are straightforward:
sudo apt update && sudo apt upgrade dragonflyRestart after upgrading:
sudo systemctl restart dragonflyTroubleshooting
Service fails to start
Check journalctl -u dragonfly. Common causes: misconfigured flag in the conf file or incorrect permissions on /var/lib/dragonfly.
Cannot connect from application
Verify the bind address matches where you're connecting from. If the app is on the same host, 127.0.0.1 is correct. If remote, ensure UFW allows the connection.
High memory usage
Confirm --maxmemory is set. Without it, DragonflyDB will use all available RAM. Check with redis-cli INFO memory.
Slow performance
Verify transparent huge pages are disabled and vm.overcommit_memory is set to 1. Confirm kernel 5.10+ — RamNode Ubuntu 22.04 images meet this requirement.
Next Steps
- Set up replication across two RamNode VPS instances for high availability
- Explore the Dragonfly Kubernetes Operator for containerized stacks
- Review the full flag reference to tune behavior for your workload
- Benchmark your setup with the official DragonflyDB benchmarking guide
