Configuration

Valkey is configured via the valkey.conf file. This page covers the most important settings for production environments.

Network

OptionDefaultDescription
bind127.0.0.1Network interface to bind to. In production, bind to a specific IP
port6379Listening port
tcp-backlog511TCP connection queue length; increase to 1024+ for high concurrency
timeout0Client idle timeout (seconds); 0 means no automatic disconnect
tcp-keepalive300TCP heartbeat interval (seconds) for detecting dead connections

Memory Management

Memory configuration is the core of Valkey tuning. Key settings:

confCopy
# Maximum memory limit (must be set)
maxmemory 2gb

# Eviction policy
# allkeys-lru  - Evict least recently used among all keys (recommended for caching)
# volatile-lru - Evict only keys with expiry set
# noeviction   - No eviction, return error when memory is full (default)
maxmemory-policy allkeys-lru

# LRU sampling precision (higher = more accurate but uses more CPU)
maxmemory-samples 10

Recommendation: Always set maxmemory. Without it, Valkey will keep consuming memory until the system OOM killer terminates it.

Persistence

RDB Snapshots

confCopy
# RDB trigger: at least 1 key change within 900 seconds
save 900 1
save 300 10
save 60 10000

# RDB filename and path
dbfilename dump.rdb
dir /var/lib/valkey

# Stop writes on BGSAVE error
stop-writes-on-bgsave-error yes

# Compress RDB file
rdbcompression yes

AOF Log

confCopy
# Enable AOF
appendonly yes

# Fsync policy
# always   - fsync every command (safest, slowest)
# everysec - fsync every second (recommended, at most 1s data loss)
# no       - Let OS decide (fastest, may lose data)
appendfsync everysec

# AOF rewrite (auto-compress log)
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

Security

confCopy
# Set password
requirepass your-strong-password-here

# Rename dangerous commands (prevent accidental use)
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command CONFIG ""

# ACL users (Valkey 6.0+)
user admin on >password ~* +@all

Security Checklist: In production, you must: set requirepass, restrict bind address, disable or rename dangerous commands, and enable TLS for cross-public-network communication.

Runtime Modification

Most settings can be modified dynamically via commands without restart:

valkeyCopy
# View current config
CONFIG GET maxmemory

# Modify dynamically (takes effect immediately, not written to config file)
CONFIG SET maxmemory 4gb

# Persist to config file
CONFIG REWRITE