Tuning the Redis Server
Purpose
You can adjust Redis parameters to improve the Redis performance.
Procedure
You can set the parameters of each Redis instance by editing the redis.conf file. Select the synchronization policy that is most suitable for your application scenario.
Parameter |
Description |
Default Value |
Option |
|---|---|---|---|
appendfsync |
Specifies the synchronization policy used when Redis writes data to drives. The options are as follows:
|
everysec |
|
appendonly |
Indicates whether to enable the persistence function of Redis. If this parameter is set to yes, Redis uses the append-only file to record all write operations when it is running. |
no |
|
cluster-require-full-coverage |
Indicates whether to allocate all slots in the cluster to nodes. By default, if a slot is not allocated with any available instance, the Redis cluster stops receiving query requests. In this case, if some instances in the cluster are faulty (for example, some slots are not allocated), the entire cluster is unavailable. Once all slots are allocated, the cluster automatically becomes available. |
yes |
|
maxmemory |
Specifies the maximum memory size occupied by Redis, in MB. |
1024 |
1 to 1048576 |
maxmemory-policy |
Specifies the policy for clearing data when the maximum memory limit is reached. The options are as follows:
|
noeviction |
|
rdbchecksum |
Indicates whether to enable RDB verification. To prevent RDB persistent file errors, you are advised to enable RDB verification. |
yes |
|
rdbcompression |
Indicates whether to compress data when Redis performs RDB persistence. |
yes |
|
stop-writes-on-bgsave-error |
Specifies the action of handling an error that occurs when Redis performs a background persistence operation (bgsave). If this parameter is set to yes, Redis stops accepting write operations when an error occurs in the bgsave operation until the administrator manually rectifies the error. |
yes |
|
activerehashing |
Indicates whether to reset the hash table. If this parameter is set to yes, Redis uses 1 ms CPU time to re-hash the Redis hash table every 100 ms, reducing the memory usage. If the application scenario has strict time requirements, set this parameter to no. If the application scenario does not have strict time requirements, set this parameter to yes so that the memory can be released as quickly as possible. |
no |
|
activedefrag |
Indicates whether to enable defragmentation. If this parameter is set to yes, Redis automatically performs defragmentation when the memory usage exceeds the threshold to reduce memory fragments and improve memory utilization. |
no |
|