Skip to content

System tuning guide

ᴀɴᴛᴏɴ ɴᴏᴠᴏᴊɪʟᴏᴠ edited this page Nov 3, 2023 · 5 revisions

▲ All commands must be executed with superuser (root) privileges.

1. Tuning the kernel memory

Under high performance conditions, we noticed the occasional blip in performance due to memory allocation. It turns out this was a known issue with transparent hugepages.

Create a file /etc/tuned/no-thp/tuned.conf with this content:

[vm]
transparent_hugepages=never

[script]
script=no-defrag.sh

Create a file /etc/tuned/no-thp/no-defrag.sh with this content:

#!/bin/sh

. /usr/lib/tuned/functions

start() {
  echo never > /sys/kernel/mm/transparent_hugepage/defrag
  return 0
}

stop() {
  return 0
}

process $@

Make this file executable by the next command:

chmod +x /etc/tuned/no-thp/no-defrag.sh

Then enable the new profile using the next command:

tuned-adm profile no-thp

2. Tuning the kernel

To ensure that Redis handles a large number of connections in a high-performance environment tuning the following kernel parameters is recommended. Create file /etc/sysctl.d/50-rds.conf and add these lines to it:

# Tuning for RDS and Redis
vm.overcommit_memory = 1
vm.swappiness = 10
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_congestion_control = htcp
net.core.somaxconn = 2048
net.ipv4.tcp_max_syn_backlog = 32768

Then execute this command to apply configuration:

sysctl -p /etc/sysctl.d/50-rds.conf

3. Set file descriptor limits

Create file /etc/security/limits.d/50-rds.conf and add these lines to it:

redis		 soft	 nofile		 10240
redis		 hard	 nofile		 10240

These limits will be applied automatically, so there are no additional actions to do.

4. Add sudoers configuration

RDS requires sudo privileges for all commands, so you will need to configure sudoers for it users.

Create file /etc/sudoers.d/rds and add these lines to it:

Cmnd_Alias RDS = /usr/bin/rds

# Allow group "rds" to run RDS without password
%rds  ALL=(ALL:ALL) NOPASSWD: RDS

Or you can add these lines directly to the /etc/sudoers file.

More info about system configuration can be found at http://redis.io/topics/admin.