You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/redis_tune/_index.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,18 +3,18 @@ title: Learn how to tune Redis
3
3
4
4
minutes_to_complete: 30
5
5
6
-
who_is_this_for: This is an advanced topic for software developers who want to deploy Redis on Arm-based servers and follow best practices to get performance benefits.
6
+
who_is_this_for: This is an advanced topic for software developers who want to tune Redis on Arm-based servers and evaluate performance-sensitive configuration settings.
7
7
8
8
learning_objectives:
9
9
- Learn about kernel parameters that can impact Redis performance
10
10
- Learn about compiler and libraries that can impact Redis performance
11
-
- Tune a Redis configuration file for deployment
11
+
- Tune Redis server configuration for improved performance
12
12
13
13
prerequisites:
14
-
- Cloud or bare-metal installation of an Redis file server
14
+
- Cloud or bare-metal installation of a Redis server
15
15
- Review [Learn how to deploy Redis](/learning-paths/servers-and-cloud-computing/redis/) if you do not already have Redis setup
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/redis_tune/kernel_comp_lib.md
+46-29Lines changed: 46 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,41 +4,53 @@ weight: 2
4
4
layout: "learningpathall"
5
5
---
6
6
7
-
In this section you can get an overview of the linux kernel, compiler and OpenSSL settings that impact the performance of Redis.
7
+
This section gives an overview of Linux kernel, compiler, and OpenSSL settings that can impact Redis performance.
8
8
9
-
## Kernel configuration
9
+
## Kernel Configuration
10
10
11
-
The profile of requests made by clients will differ based on the use case. This means there is no onesizefitsall set of tuning parameters for Redis. Use the information below as general guidance to tune Redis.
11
+
The request profile varies by use case, so there is no one-size-fits-all set of tuning parameters for Redis. Use the information below as a starting point, then measure the impact for your workload.
12
12
13
13
### Memory Management
14
14
15
-
The memory related kernel parameters can be changed either temporarily through the `/proc` file system or permanently using the `sysctl` command.
16
-
To improve memory utilization on your system, use the following commands:
15
+
Memory-related kernel parameters can be changed temporarily with `sysctl -w` or made persistent by adding them to a file under `/etc/sysctl.d/`.
16
+
17
+
Use the following commands to apply the settings immediately:
* Enabling overcommit_memory to avoid out of memory space issues. If the overcommit memory value is 0 then there is chance that Redis will get an OOM (out of memory) error.
26
-
*`vm.swappiness`:
27
-
* When the Redis server consuming high memory, configuring the swappiness to its lowest value could be helpful.
24
+
To make the settings persistent across reboots, create a Redis-specific sysctl file:
25
+
26
+
```console
27
+
printf "vm.overcommit_memory = 1\nvm.swappiness = 1\n" | sudo tee /etc/sysctl.d/99-redis.conf
28
+
sudo sysctl --system
29
+
```
30
+
31
+
`vm.overcommit_memory` should be set to `1` so Redis background save and rewrite operations are less likely to fail during `fork()`.
32
+
33
+
`vm.swappiness` controls how aggressively Linux swaps memory pages. A low value helps reduce Redis latency caused by paging under memory pressure.
28
34
29
35
### Transparent Huge Page
30
36
31
-
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.
37
+
Transparent Huge Pages (THP) can increase Redis latency and memory use, especially when Redis forks for RDB snapshots or AOF rewrite. Disable THP at the kernel level on systems used for Redis performance tuning.
38
+
39
+
Check the current THP setting:
32
40
33
-
The command to disable this setting is shown below:
41
+
```console
42
+
cat /sys/kernel/mm/transparent_hugepage/enabled
43
+
```
44
+
45
+
Disable THP until the next reboot:
34
46
35
47
```console
36
-
sudo echo never > /sys/kernel/mm/transparent_hugepage/enabled
48
+
echo never | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
37
49
```
38
50
39
51
### Linux Network Stack
40
52
41
-
The Linux Network stack settings can be changed in the `/etc/sysctl.conf` file, or by using the `sysctl` command.
53
+
Linux network stack settings can be changed temporarily with `sysctl -w`or made persistent by adding them to a file under `/etc/sysctl.d/`.
42
54
43
55
Documentation on each of the parameters discussed below can be found in the [admin-guide](https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/sysctl/net.rst) and [networking](https://github.com/torvalds/linux/blob/master/Documentation/networking/ip-sysctl.rst) documentation within the Linux source.
44
56
@@ -48,34 +60,39 @@ Run the command below to list all kernel parameters.
48
60
sudo sysctl -a
49
61
```
50
62
51
-
Shown below are the network stack settings used for performance testing.
63
+
Shown below are network stack settings used for Redis performance tuning.
52
64
53
65
```console
54
66
sudo sysctl -w net.core.somaxconn=65535
55
67
sudo sysctl -w net.ipv4.tcp_max_syn_backlog=65535
56
-
57
68
```
58
69
59
-
These settings open up the network stack to make sure it is not a bottleneck.
70
+
These settings raise connection queue limits so the kernel is less likely to be the bottleneck during high connection churn.
60
71
61
72
*`net.core.somaxconn`:
62
-
* This setting is used to select the maximum number of connections the kernel will allow.
73
+
* This setting controls the maximum listen backlog the kernel allows.
63
74
* If the Redis server is expected to support a large number of clients, it may be helpful to increase this parameter.
64
-
* A value of 65535 is probably excessively large for production. In practice, this just needs to be large enough to support the peak number of connections that will be made.
75
+
* The value should be at least as large as the Redis `tcp-backlog` setting.
76
+
* A value of 65535 is probably too large for production. In practice, this only needs to support the expected peak connection backlog.
65
77
*`net.ipv4.tcp_max_syn_backlog`:
66
-
* This setting is used to select the maximum number of connection requests that are pending but not established yet.
67
-
* A value of 65535 is probably excessively large for production. In practice, this just needs to be large enough to support the peak number of connection requests that will be made.
78
+
* This setting controls the maximum number of connection requests that are pending but not established.
79
+
* A value of 65535 is probably too large for production. In practice, this only needs to support the expected peak rate of new connection attempts.
68
80
69
81
70
-
## Compiler Considerations
82
+
## Compiler Considerations
71
83
72
-
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](/learning-paths/servers-and-cloud-computing/migration/c/) section of the [Migrating applications to Arm servers](/learning-paths/servers-and-cloud-computing/migration/) learning path.
84
+
If you build Redis from source, use a recent GCC version from your Linux distribution. Compiler flags such as `-mcpu` and `-flto` can change performance, but they should be tested against your workload before use. Usage of these flags is explained in the [Migrating C/C++ applications](/learning-paths/servers-and-cloud-computing/migration/c/) section of the [Migrating applications to Arm servers](/learning-paths/servers-and-cloud-computing/migration/) learning path.
73
85
74
-
If you need to understand how to configure a build of Redis. Please review the [build Redis from source](https://redis.io/docs/latest/operate/oss_and_stack/install/archive/install-redis/install-redis-from-source/).
86
+
For Redis build instructions, review the [build Redis from source](https://redis.io/docs/latest/operate/oss_and_stack/install/archive/install-redis/install-redis-from-source/) documentation.
75
87
76
-
## OpenSSL Considerations
88
+
## OpenSSL Considerations
77
89
78
-
Redis relies on [OpenSSL](https://www.openssl.org/) 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.
90
+
Redis uses [OpenSSL](https://www.openssl.org/) for TLS. TLS adds encryption and integrity-check overhead, so it can reduce the maximum throughput of a Redis instance. Typically, the Linux distribution default OpenSSL version is sufficient.
79
91
80
-
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.
92
+
To build Redis with TLS support, install the OpenSSL development libraries for your distribution and build Redis with:
93
+
94
+
```console
95
+
make BUILD_TLS=yes
96
+
```
81
97
98
+
Only test a newer OpenSSL version if TLS is part of the workload. If clients connect without TLS, OpenSSL does not affect Redis command throughput.
0 commit comments