Databases

    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

    ComponentMinimumRecommended
    OSUbuntu 20.04Ubuntu 22.04 LTS
    Kernel4.195.10+
    RAM1 GB4 GB+
    CPU1 vCPU2+ vCPUs
    Disk10 GB20 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.

    1

    Update Your System

    Update packages
    sudo apt update && sudo apt upgrade -y

    Reboot if a kernel update was applied:

    Reboot
    sudo reboot
    2

    Install DragonflyDB via APT

    DragonflyDB maintains an official APT repository for Debian/Ubuntu.

    Add GPG key
    sudo curl -Lo /usr/share/keyrings/dragonfly-keyring.public \
      https://packages.dragonflydb.io/pgp-key.public
    Add repository
    sudo curl -Lo /etc/apt/sources.list.d/dragonfly.sources \
      https://packages.dragonflydb.io/dragonfly.sources
    Install
    sudo apt update && sudo apt install -y dragonfly
    3

    Configure DragonflyDB

    Create a configuration file with production-ready settings:

    Create config directory
    sudo mkdir -p /etc/dragonfly
    sudo nano /etc/dragonfly/dragonfly.conf
    /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 to 0.0.0.0 without 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:

    Create data dir
    sudo mkdir -p /var/lib/dragonfly
    sudo chown dragonfly:dragonfly /var/lib/dragonfly
    4

    Configure the systemd Service

    The APT package installs a default systemd unit. Point it at your config file with a drop-in override:

    Edit service
    sudo systemctl edit dragonfly

    Add the following:

    Override content
    [Service]
    ExecStart=
    ExecStart=/usr/bin/dragonfly --flagfile=/etc/dragonfly/dragonfly.conf

    The first empty ExecStart= clears the default command before setting the new one.

    5

    Enable and Start the Service

    Enable and start
    sudo systemctl daemon-reload
    sudo systemctl enable --now dragonfly

    Check that it started cleanly:

    Check status
    sudo systemctl status dragonfly

    If not running, check logs:

    View logs
    sudo journalctl -u dragonfly -n 50 --no-pager
    6

    Verify Connectivity

    Install the Redis CLI if you don't already have it:

    Install redis-tools
    sudo apt install -y redis-tools

    Connect and authenticate:

    Test PING
    redis-cli -p 6379 -a YOUR_STRONG_PASSWORD_HERE PING

    A PONG response confirms DragonflyDB is running. Run an info check:

    Check server info
    redis-cli -p 6379 -a YOUR_STRONG_PASSWORD_HERE INFO server

    You'll see dragonfly_version in the output confirming you're talking to DragonflyDB.

    7

    Firewall Configuration

    If your app runs on the same VPS, since DragonflyDB is bound to 127.0.0.1, no additional rule is needed:

    Basic UFW
    sudo ufw allow ssh
    sudo ufw enable

    If your app runs on a separate VPS in the same datacenter, allow access from that private IP only:

    Allow specific IP
    sudo ufw allow from YOUR_APP_SERVER_IP to any port 6379

    Then update your DragonflyDB bind address to include the private network interface and restart the service.

    8

    Kernel Tuning (Optional but Recommended)

    Disable transparent huge pages (reduces latency spikes):

    Disable THP
    echo never | sudo tee /sys/kernel/mm/transparent_hugepage/enabled

    Increase max open files:

    /etc/security/limits.conf additions
    dragonfly soft nofile 65536
    dragonfly hard nofile 65536

    Adjust overcommit memory:

    Set and persist
    echo 1 | sudo tee /proc/sys/vm/overcommit_memory
    echo "vm.overcommit_memory = 1" | sudo tee -a /etc/sysctl.conf
    sudo sysctl -p
    9

    Snapshot 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 config addition
    --aof_rewrite_min_size=128mb
    Restart service
    sudo systemctl restart dragonfly

    For 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.

    10

    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):

    Node.js example
    const Redis = require('ioredis');
    const client = new Redis({
      host: '127.0.0.1',
      port: 6379,
      password: 'YOUR_STRONG_PASSWORD_HERE',
    });

    Python (redis-py):

    Python example
    import redis
    client = redis.Redis(host='127.0.0.1', port=6379, password='YOUR_STRONG_PASSWORD_HERE')

    PHP (Predis):

    PHP example
    $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

    TaskCommand
    Startsudo systemctl start dragonfly
    Stopsudo systemctl stop dragonfly
    Restartsudo systemctl restart dragonfly
    View logssudo journalctl -u dragonfly -f
    Check statussudo systemctl status dragonfly
    Manual saveredis-cli -a PASSWORD BGSAVE
    Memory usageredis-cli -a PASSWORD INFO memory

    Upgrading DragonflyDB

    Since you installed via APT, upgrades are straightforward:

    Upgrade
    sudo apt update && sudo apt upgrade dragonfly

    Restart after upgrading:

    Restart
    sudo systemctl restart dragonfly

    Troubleshooting

    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