Skip to content

Instantly share code, notes, and snippets.

  • Select an option

  • Save jamesbjackson/b9800f25bb0aa7244ba7ad403d178f1c to your computer and use it in GitHub Desktop.

Select an option

Save jamesbjackson/b9800f25bb0aa7244ba7ad403d178f1c to your computer and use it in GitHub Desktop.
Fix redis server startup warnings, redis tuning performance on Ubuntu 16.04

Maximum Open Files

You requested maxclients of 10000 requiring at least 10032 max file descriptors.
Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.

Solution:

Edit systemd service file sudo vim /etc/systemd/system/redis.service

[Service]
...
User=redis
Group=redis
# should be fine as long as you add it under [Service] block
LimitNOFILE=65536

Then you must daemon reload and restart the service

sudo systemctl daemon-reload sudo systemctl restart redis.service

To check if it works, try to cat proc limits cat /proc/PID/limits and you will see Max open files 65536 65536 files Max locked memory 65536 65536 bytes

Socket Maximum Connection

WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

Memory Overcommit

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

Solution:

Since these two are related, we will solve it at once.

sudo vim /etc/sysctl.conf

# Add at the bottom of file
vm.overcommit_memory = 1
net.core.somaxconn=1024

Now for these configs to work, you need to reload the config sudo sysctl -p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment