Redis Configuration Essentials (redis.conf)
Redis Configuration File Overview
The Redis configuration file resides in the Redis installation directory with the filename redis.conf.
Configuration Methods
Method 1: Direct modification of the redis.conf file content.
Method 2: Using the CONFIG command to view or modify settings.
CONFIG Command Usage
Viewing Configuration:
# Retrieve specific configuration item or use * for all items
CONFIG GET config_item_name
Setting Configuration:
# Modify configuration value
CONFIG SET config_item_name new_value
Essential Configuration Parameters
| Parameter Name | Description |
|---|---|
| daemonize no (default) | Controls whether Redis runs as a background process. Set to yes to enable daemon mode. |
| pidfile /var/run/redis.pid | When running as a daemon, Redis writes its process ID to this file location. |
| port 6379 | Defines the port Redis listens on. Default is 6379, chosen based on the numeric representation of "MERZ" from Italian singer Alessia Merz's name. |
| bind 127.0.0.1 | Specifies the host address to bind to. |
| timeout 300 | Closes client connections after specified seconds of inactivity. Set to 0 to disable. |
| loglevel verbose | Sets logging level: debug, verbose, notice, warning. Default is verbose. |
| logfile stdout | Determines log output method. Defaults to standard output. |
| databases 16 | Number of databases available. Use SELECT <database_id> to choose database. |
| save <seconds> <changes> | Defines synchronization conditions. Default includes: save 900 1 save 300 10 save 60 10000 This means sync after 1 change in 900 seconds, 10 changes in 300 seconds, or 10000 changes in 60 seconds. |
| rdbcompression yes | Enables compression when storing data locally using LZF algorithm. |
| dbfilename dump.rdb | Name of the local database file. Default is dump.rdb. |
| dir ./ | Directory where local database files are stored. |
| slaveof <master_ip> <master_port> | Configures master server IP and port when operating as slave instance. |
| masterauth <master_password> | Password for authenticating with protected master server. |
| requirepass foobared | Sets connection password. Clients must authenticate using AUTH command. |
| maxclients 128 | Maximum concurrent client connections. Set to 0 for unlimited. |
| maxmemory <bytes> | Memory limit for Redis. When exceeded, Redis attempts to remove expired keys before refusing write operations. |
| appendonly no | Enables append-only file logging for each update operation. Default is disabled. |
| appendfilename appendonly.aof | Name of the append-only log file. Default is appendonly.aof. |
| appendfsync everysec | Log synchronization strategy with three options: no: OS-controlled sync always: Sync after each operation everysec: Sync every second (default) |
| vm-enabled no | Enables virtual memory mechanism to store less-frequently accessed data on disk. |
| vm-swap-file /tmp/redis.swap | Path to virtual memory swap file. Should not be shared between instances. |
| vm-max-memory 0 | Threshold for moving data to virtual memory. When set to 0, all values are stored on disk. |
| vm-page-size 32 | Page size for swap files. Recommended 32-64 bytes for small objects, larger sizes for bigger objects. |
| vm-pages 134217728 | Number of pages in swap file. Page table consumes memory at rate of 1 byte per 8 pages. |
| vm-max-threads 4 | Thread count for swap file operations. Should not exceed CPU core count. |
| glueoutputbuf yes | Combines smaller response packets into single responses for efficiency. |
| hash-max-zipmap-entries 64 hash-max-zipmap-value 512 | Thresholds for switching to specialized hash algorithm for large datasets. |
| activerehashing yes | Enables active rehashing for improved performance during hash table resizing. |
| include /path/to/local.conf | Includes additional configuration files for multi-instance setups. |