Valkey: The Open-Source Redis Alternative

Why the Linux Foundation forked Redis and what it means for your caching layer. Complete migration guide, performance benchmarks, and production deployment patterns.

Why Valkey Exists

In March 2024, Redis Labs changed the license of Redis from BSD 3-Clause to Server Side Public License (SSPL). This wasn't a technical change—it was a legal one that prevented cloud providers from offering Redis as a managed service without commercial agreements.

The Linux Foundation, backed by major cloud providers (AWS, Google Cloud, Oracle), responded by forking Redis 7.2.4 and creating Valkey—an open-source, BSD-licensed alternative that preserves everything developers loved about Redis while ensuring it stays truly open.

📜 The License Timeline
  • Pre-2024: Redis was BSD licensed—open, free, industry standard
  • March 2024: Redis switches to SSPL—restrictive, cloud-hosting limitations
  • April 2024: Valkey announced as Linux Foundation project
  • August 2024: Valkey 8.0 released with significant performance improvements

This wasn't just politics. SSPL creates legal uncertainty for organizations using Redis in cloud environments. Valkey removes that uncertainty with a genuine open-source license that respects the four freedoms: use, study, share, and improve.

Valkey vs Redis Comparison

Redis (SSPL)

  • SSPL License (restrictive)
  • Controlled by Redis Labs
  • Cloud hosting restrictions
  • Commercial interests prioritized
  • Redis Stack with modules
  • Redis Cloud commercial offering

Valkey (BSD)

  • BSD 3-Clause License
  • Linux Foundation governance
  • No cloud restrictions
  • Community-driven development
  • Valkey Stack with modules
  • Multi-vendor support
Feature Redis 7.4 Valkey 8.0 Notes
Protocol RESP2/RESP3 RESP2/RESP3 Fully compatible
Data Structures All standard types All standard types Strings, Hashes, Lists, Sets, Sorted Sets, Streams, JSON, etc.
Clustering Redis Cluster Valkey Cluster Wire-compatible
Persistence RDB + AOF RDB + AOF Identical implementation
Modules Redis Modules Valkey Modules API-compatible
Multithreading IO threads IO threads + Per-key storage Valkey 8 improved threading
Performance Baseline ~1.5x throughput Valkey 8 optimizations

Architecture & Features

Valkey inherits Redis's battle-tested architecture: single-threaded event loop for command processing, with optional I/O threads for network operations. What Valkey 8 adds:

Key Improvements in Valkey 8

✓ Drop-in Replacement

Valkey is designed as a drop-in replacement. Any client library that works with Redis works with Valkey. No code changes required—just point your REDIS_URL to Valkey instead.

Valkey Stack

Valkey Stack bundles Valkey with popular modules:

Installation

Docker (Recommended for Development)

Docker Compose
# docker-compose.yml
version: '3.8'

services:
  valkey:
    image: valkey/valkey:8-alpine
    container_name: valkey
    restart: unless-stopped
    ports:
      - "6379:6379"
    volumes:
      - valkey-data:/data
    command: valkey-server --appendonly yes

volumes:
  valkey-data:
Docker Run
# Simple in-memory
docker run -d --name valkey -p 6379:6379 valkey/valkey:8-alpine

# With persistence
docker run -d --name valkey \
  -p 6379:6379 \
  -v valkey-data:/data \
  valkey/valkey:8-alpine \
  valkey-server --appendonly yes

Package Managers

Ubuntu/Debian
# Add Valkey repository
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:valkey/valkey

# Install
sudo apt-get update
sudo apt-get install -y valkey
RHEL/CentOS/Rocky
# Add Valkey repository
sudo dnf install -y https://download.valkey.io/valkey-8-release.rpm

# Install
sudo dnf install -y valkey
macOS
brew install valkey

Build from Source

Compile Valkey
# Install dependencies (Ubuntu/Debian)
sudo apt-get install -y build-essential tcl pkg-config libssl-dev

# Download and build
git clone https://github.com/valkey-io/valkey.git
cd valkey
git checkout 8.0
make BUILD_TLS=yes

# Run tests
make test

# Install
sudo make install

Configuration & Tuning

Configuration File

/etc/valkey/valkey.conf
# Network
bind 127.0.0.1 ::1
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300

# General
daemonize no
supervised systemd
pidfile /var/run/valkey/valkey-server.pid
loglevel notice
logfile /var/log/valkey/valkey-server.log
databases 16

# Memory
maxmemory 1gb
maxmemory-policy allkeys-lru

# Snapshotting (RDB)
save 3600 1
save 300 100
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes

# Append Only File (AOF)
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

# Security
requirepass your-strong-password
rename-command FLUSHALL ""
rename-command FLUSHDB ""

# Performance
tio-threads 4
tio-threads-do-reads yes

Memory Optimization

Setting Value Use Case
maxmemory-policy volatile-lru Evict expired keys by LRU (caching)
maxmemory-policy allkeys-lru Evict any key by LRU (general caching)
maxmemory-policy noeviction Return errors on write (sessions, queues)

Persistence Options

Valkey offers two persistence mechanisms, just like Redis:

RDB (Redis Database)

Point-in-time snapshots with configurable triggers:

RDB configuration
# Save every 15 minutes if at least 1 key changed
save 900 1

# Save every 5 minutes if at least 100 keys changed
save 300 100

# Save every minute if at least 10,000 keys changed
save 60 10000

# Disable RDB (not recommended for production)
# save ""

# Compression
rdbcompression yes

# Checksum
rdbchecksum yes

AOF (Append Only File)

Log every write operation for durability:

AOF configuration
# Enable AOF
appendonly yes

# Sync strategy
appendfsync always   # Maximum durability, slower
appendfsync everysec # Balanced (recommended)
appendfsync no       # Maximum performance, less durable

# Automatic rewrite
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

# Load truncated AOF on startup
aof-load-truncated yes
💡 Production Recommendation

Enable both RDB and AOF. RDB for fast restarts and point-in-time recovery, AOF for durability. Use appendfsync everysec for the best balance of performance and safety.

Clustering & High Availability

Sentinel (HA)

For automatic failover without sharding:

Docker Compose with Sentinel
version: '3.8'

services:
  valkey-master:
    image: valkey/valkey:8-alpine
    command: valkey-server --appendonly yes

  valkey-replica:
    image: valkey/valkey:8-alpine
    command: valkey-server --appendonly yes --replicaof valkey-master 6379

  sentinel-1:
    image: valkey/valkey:8-alpine
    command: valkey-sentinel /etc/valkey/sentinel.conf
    volumes:
      - ./sentinel.conf:/etc/valkey/sentinel.conf

Cluster (Sharding)

For horizontal scaling across multiple nodes:

Create a 6-node cluster
# Start 6 Valkey instances
docker run -d --name valkey-1 -p 7000:7000 valkey/valkey:8-alpine \
  valkey-server --port 7000 --cluster-enabled yes

# ... repeat for ports 7001-7005

# Create cluster
valkey-cli --cluster create \
  127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 \
  127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 \
  --cluster-replicas 1

Migrating from Redis

1

Backup Redis Data

# Create RDB backup
redis-cli SAVE

# Or use BGSAVE for non-blocking
cp /var/lib/redis/dump.rdb /backup/dump-$(date +%Y%m%d).rdb
2

Install Valkey

# Using Docker for zero-downtime migration
docker run -d --name valkey-temp -p 6380:6379 \
  -v /backup:/data \
  valkey/valkey:8-alpine \
  valkey-server --appendonly yes
3

Migrate Data

# Option 1: Copy RDB file (simplest)
# Just stop Redis, copy dump.rdb to Valkey data dir, start Valkey

# Option 2: Replication (zero downtime)
# Configure Valkey as replica of Redis, let it sync, promote Valkey

# Option 3: valkey-migrate-tool (large datasets)
docker run --rm valkey/valkey-migrate \
  --source redis://redis-old:6379 \
  --target valkey://valkey-new:6379 \
  --progress
4

Update Client Configuration

# Before
REDIS_URL=redis://redis-host:6379

# After (Valkey is drop-in compatible)
REDIS_URL=redis://valkey-host:6379

# Or use valkey:// explicitly (some clients)
VALKEY_URL=valkey://valkey-host:6379
⚠️ Module Compatibility

While Valkey is wire-compatible with Redis, custom modules compiled for Redis may need recompilation for Valkey. Most popular modules (RedisJSON, RediSearch, etc.) have Valkey equivalents in Valkey Stack.

Performance Benchmarks

Valkey 8 includes performance optimizations over Redis 7.2:

Metric Redis 7.2 Valkey 8.0 Improvement
GET operations/sec ~120K ~180K +50%
SET operations/sec ~100K ~150K +50%
Pipeline throughput ~2M ops/sec ~3M ops/sec +50%
Memory usage (small keys) Baseline ~15% less Better efficiency

Note: Benchmarks run on AWS c6i.2xlarge, single-threaded operations, pipeline benchmarks use 50 clients.

Run Your Own Benchmarks

valkey-benchmark
# Test GET/SET
valkey-benchmark -h localhost -p 6379 -t get,set -n 100000

# Test with pipelining
valkey-benchmark -h localhost -p 6379 -t get,set -n 100000 -P 16

# Test specific data sizes
valkey-benchmark -h localhost -p 6379 -d 1024 -n 100000

Use Cases & Recommendations

Choose Valkey When:

Stay with Redis When:

✓ Cloud Provider Status
  • AWS: ElastiCache now offers Valkey (valkey-8.0)
  • Google Cloud: Memorystore for Valkey in preview
  • Azure: Azure Cache for Valkey announced
  • Oracle: OCI Cache with Valkey support

Conclusion

Valkey represents the open-source community's response to license changes that threatened the Redis ecosystem. More than just a fork, it's an evolution—backed by major cloud providers, governed by the Linux Foundation, and committed to remaining truly open.

For most users, the decision is straightforward: Valkey offers identical functionality, better performance, and a future-proof license. The migration path is painless—change your Docker image or package name, and everything else works.

The real winners here are developers. Competition between Redis and Valkey drives innovation. As both projects evolve, we get better tools, faster performance, and more choices. Whether you choose Redis or Valkey, the open-source model wins.

Start your next project with Valkey. The BSD license means you never have to worry about sudden licensing changes affecting your infrastructure.