Documentation Index
Fetch the complete documentation index at: https://mintlify.com/redis/redis/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Redis configuration can be managed through theredis.conf file or dynamically at runtime using the CONFIG command. This guide covers configuration directives, runtime management, and best practices.
Configuration File
Starting Redis with a Configuration File
Redis must be started with the configuration file path as the first argument:Unit Specifications
Redis supports convenient memory size units (case insensitive):1k=> 1000 bytes1kb=> 1024 bytes1m=> 1000000 bytes1mb=> 1024*1024 bytes1g=> 1000000000 bytes1gb=> 102410241024 bytes
CONFIG Commands
CONFIG GET
Retrieve the value of configuration parameters.CONFIG SET
Change configuration parameters at runtime without restarting Redis.CONFIG REWRITE
Persist runtime configuration changes back to theredis.conf file:
Core Configuration Directives
Network Configuration
bind
Specify which network interfaces Redis should listen on:port
Set the TCP port (default: 6379):tcp-backlog
Set the TCP listen() backlog for high-traffic environments:On Linux, ensure
/proc/sys/net/core/somaxconn and tcp_max_syn_backlog are set appropriately.tcp-keepalive
Send TCP keepalive messages to detect dead peers:timeout
Close idle client connections after N seconds (0 to disable):General Configuration
daemonize
Run Redis as a daemon:pidfile
Specify the PID file location:loglevel
Set the server verbosity level:logfile
Specify the log file path:databases
Set the number of databases:Snapshotting Configuration
save
Configure automatic RDB snapshots:stop-writes-on-bgsave-error
Stop accepting writes if background save fails:rdbcompression
Compress RDB files using LZF:rdbchecksum
Add CRC64 checksum to RDB files:dbfilename
Set the RDB filename:dir
Set the working directory for RDB and AOF files:Memory Management
maxmemory
Set a memory usage limit:maxmemory-policy
Define eviction policy when maxmemory is reached:- LRU (Least Recently Used): Updates timestamp on both read and write operations
- LRM (Least Recently Modified): Updates timestamp only on write operations
- LFU (Least Frequently Used): Tracks access frequency
maxmemory-samples
Number of keys to sample for eviction algorithms:Client Configuration
maxclients
Maximum number of simultaneous client connections:In Redis Cluster, each node uses two connections (incoming and outgoing), so size accordingly.
Module Loading
Load Redis modules at startup:Including Configuration Files
Include additional configuration files:Include directives at the beginning of the file for base configuration, or at the end to override settings.
Configuration Management Best Practices
# Test configuration file syntax
redis-server /path/to/redis.conf --test-memory 1
# Use CONFIG SET to test changes before persisting
CONFIG SET maxmemory 2gb
# Verify behavior, then:
CONFIG REWRITE
# Get all configuration
CONFIG GET *
# Check specific security settings
CONFIG GET bind
CONFIG GET protected-mode
CONFIG GET requirepass
Runtime Configuration Examples
Example: Adjust Memory Settings
Example: Enable Logging
Example: Adjust Snapshot Frequency
Configuration Reset
Reset specific configuration parameters to their default values by usingCONFIG SET with appropriate values, or edit redis.conf and restart Redis.