docker.recipes

KeyDB

beginner

High-performance Redis fork with multithreading and active replication.

Overview

KeyDB is a high-performance fork of Redis that introduces multithreading capabilities and active-active replication while maintaining full compatibility with Redis protocols and commands. Originally developed by Snap Inc. (Snapchat), KeyDB addresses Redis's single-threaded limitation by utilizing multiple CPU cores, delivering significantly better performance on multi-core systems. This deployment runs KeyDB as a single container using the eqalpha/keydb image, configured with 2 server threads to leverage multiple CPU cores while maintaining the familiar Redis interface. The container exposes the standard Redis port 6379 and includes password authentication for security. This setup is ideal for organizations looking to upgrade from Redis without changing their application code, developers who need better performance from their caching layer, or teams exploring Redis alternatives that can better utilize modern multi-core hardware.

Key Features

  • Multi-threaded architecture utilizing 2 CPU cores compared to Redis's single-threaded design
  • Complete Redis protocol compatibility allowing drop-in replacement for existing Redis applications
  • Active-active replication support for multi-master database configurations
  • Enhanced performance on multi-core systems through parallel request processing
  • Password authentication with configurable security settings
  • Persistent data storage with automatic background saves and RDB snapshots
  • Memory-efficient operations with improved garbage collection over standard Redis
  • Support for all standard Redis data structures including strings, hashes, lists, sets, and sorted sets

Common Use Cases

  • 1High-traffic web applications requiring faster cache performance than single-threaded Redis
  • 2Multi-region deployments needing active-active replication for reduced latency
  • 3Development teams migrating from Redis who want better multi-core utilization
  • 4Gaming platforms handling concurrent user sessions and real-time leaderboards
  • 5E-commerce sites managing shopping carts and session data with high concurrency
  • 6API backends requiring sub-millisecond response times for cached data
  • 7IoT applications processing high-frequency sensor data and metrics

Prerequisites

  • Docker and Docker Compose installed on a multi-core system (minimum 2 CPU cores recommended)
  • At least 1GB of available RAM for KeyDB operations and data storage
  • Port 6379 available and not conflicting with existing Redis installations
  • Basic familiarity with Redis commands and data structures
  • Environment variable KEYDB_PASSWORD configured for authentication
  • Understanding of in-memory database concepts and persistence options

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 keydb:
3 image: eqalpha/keydb:latest
4 container_name: keydb
5 restart: unless-stopped
6 command: keydb-server --server-threads 2 --requirepass ${KEYDB_PASSWORD}
7 volumes:
8 - keydb_data:/data
9 ports:
10 - "6379:6379"
11 networks:
12 - keydb-network
13
14volumes:
15 keydb_data:
16
17networks:
18 keydb-network:
19 driver: bridge

.env Template

.env
1KEYDB_PASSWORD=changeme

Usage Notes

  1. 1Docs: https://docs.keydb.dev/
  2. 2Redis-compatible on port 6379 - use any Redis client
  3. 3Multithreaded - utilizes all CPU cores (Redis is single-threaded)
  4. 4Drop-in Redis replacement - same protocol and commands
  5. 5Active-active replication for multi-master setups
  6. 6Test: redis-cli -a YOUR_PASSWORD ping

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 keydb:
5 image: eqalpha/keydb:latest
6 container_name: keydb
7 restart: unless-stopped
8 command: keydb-server --server-threads 2 --requirepass ${KEYDB_PASSWORD}
9 volumes:
10 - keydb_data:/data
11 ports:
12 - "6379:6379"
13 networks:
14 - keydb-network
15
16volumes:
17 keydb_data:
18
19networks:
20 keydb-network:
21 driver: bridge
22EOF
23
24# 2. Create the .env file
25cat > .env << 'EOF'
26KEYDB_PASSWORD=changeme
27EOF
28
29# 3. Start the services
30docker compose up -d
31
32# 4. View logs
33docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/keydb/run | bash

Troubleshooting

  • Connection refused on port 6379: Verify the keydb container is running with 'docker ps' and check firewall settings
  • Authentication failed when connecting: Ensure KEYDB_PASSWORD environment variable is set and matches client configuration
  • KeyDB container keeps restarting: Check available memory and ensure no other service is using port 6379
  • Poor performance despite multithreading: Increase server-threads parameter beyond 2 if you have more CPU cores available
  • Data loss after container restart: Verify keydb_data volume is properly mounted and check KeyDB persistence settings
  • Redis clients reporting protocol errors: Ensure client libraries support the Redis protocol version used by KeyDB

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Components

keydb

Tags

#keydb#redis#cache#in-memory#fast

Category

Database Stacks
Ad Space