In this section you can get an overview of the linux kernel, compiler and OpenSSL settings that impact the performance of Redis.
The profile of requests made by clients will differ based on the use case. This means there is no one size fits all set of tuning parameters for Redis. Use the information below as general guidance to tune Redis.
The memory related kernel parameters can be changed either temporarily through the /proc
file system or permanently using the sysctl
command.
To improve memory utilization on your system, use the following commands:
sudo echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sudo echo 'vm.swappiness=1' >> /etc/sysctl.conf
Understand the parameters:
vm.overcommit_memory
:vm.swappiness
:Redis by default will disable transparent huge page (THP) if it is enabled for Redis process to avoid latency problems. You should disable this parameter in case this config has no effect.
The command to disable this setting is shown below:
sudo echo never > /sys/kernel/mm/transparent_hugepage/enabled
The Linux Network stack settings can be changed in the /etc/sysctl.conf
file, or by using the sysctl
command.
Documentation on each of the parameters discussed below can be found in the admin-guide and networking documentation within the Linux source.
Run the command below to list all kernel parameters.
sudo sysctl -a
Shown below are the network stack settings used for performance testing.
sudo sysctl -w net.core.somaxconn=65535
sudo sysctl -w net.ipv4.tcp_max_syn_backlog=65535
These settings open up the network stack to make sure it is not a bottleneck.
net.core.somaxconn
:net.ipv4.tcp_max_syn_backlog
:The easiest way to gain performance is to use the latest version of GCC. Aside from that, the flag -mcpu
and -flto
can be used to potentially gain additional performance. Usage of these flags is explained in the
Migrating C/C++ applications
section of the
Migrating applications to Arm servers
learning path.
If you need to understand how to configure a build of Redis. Please review the build Redis from source .
Redis relies on OpenSSL for cryptographic operations. Thus, the version of OpenSSL used with Redis (and the GCC version and switches used to compile it) can impact performance. Typically using the Linux distribution default version of OpenSSL is sufficient.
However, it is possible to use newer versions of OpenSSL which could yield performance improvements. This is achieved by using the --with-openssl
switch when configuring the Redis build. Point this switch to the directory that contains the source code of the version of OpenSSL you’d like to have Redis link to. The Redis build system takes care of the rest. There is also a --with-openssl-opt
switch which allows you to add options to the build for OpenSSL.