geerlingguy / ansible-role-redis

Ansible Role - Redis
https://galaxy.ansible.com/geerlingguy/redis/
MIT License
254 stars 197 forks source link

New Options To Fix Warning Messages #29

Closed dac514 closed 4 years ago

dac514 commented 6 years ago

Hi, we use this Ansible Role. So far so good but we get the following warnings when starting Redis:

`

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

`

`

2 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.

`

`

3 WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

`

Although these are only warnings it would be nice to have the option to fix them. This blog post describes all these warnings and gives (bash like) solutions on how to get rid of them:

I'm envisioning some new options a user could set, theoretical examples:

Here are some Ansible snippets with the same solutions as described in the blog post that could be inspiring.

Fix for 1 and 2

https://github.com/QafooLabs/redis-testing/blob/master/provision.yml

Fix for 2

https://github.com/akishin/ansible-playbooks/blob/master/gitlab-unicorn/roles/redis/tasks/main.yml

Fix for 3

https://github.com/jamielinux/ansible-discourse/blob/master/roles/redis/files/disable-transparent-huge-pages.service

There are many other examples in GitHub but no reusable Ansible role repo seems to have all of them in one place.

Thank you for your consideration.

geerlingguy commented 6 years ago

Confirmed the following on a fresh Fedora 27 installation:

# cat /var/log/redis/redis-server.log
179:C 27 Apr 18:02:40.179 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
179:C 27 Apr 18:02:40.179 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=179, just started
179:C 27 Apr 18:02:40.180 # Configuration loaded
179:C 27 Apr 18:02:40.180 * supervised by systemd, will signal readiness
179:M 27 Apr 18:02:40.181 * Running mode=standalone, port=6379.
179:M 27 Apr 18:02:40.181 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
179:M 27 Apr 18:02:40.181 # Server initialized
179:M 27 Apr 18:02:40.181 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
179:M 27 Apr 18:02:40.181 * Ready to accept connections
179:M 27 Apr 18:02:40.871 # User requested shutdown...
179:M 27 Apr 18:02:40.871 * Saving the final RDB snapshot before exiting.
179:M 27 Apr 18:02:40.875 * DB saved on disk
179:M 27 Apr 18:02:40.875 * Removing the pid file.
179:M 27 Apr 18:02:40.875 # Redis is now ready to exit, bye bye...
214:C 27 Apr 18:02:40.881 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
214:C 27 Apr 18:02:40.881 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=214, just started
214:C 27 Apr 18:02:40.881 # Configuration loaded
214:C 27 Apr 18:02:40.881 * supervised by systemd, will signal readiness
214:M 27 Apr 18:02:40.883 * Running mode=standalone, port=6379.
214:M 27 Apr 18:02:40.884 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
214:M 27 Apr 18:02:40.884 # Server initialized
214:M 27 Apr 18:02:40.884 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
214:M 27 Apr 18:02:40.884 * DB loaded from disk: 0.000 seconds
214:M 27 Apr 18:02:40.884 * Ready to accept connections

Note that I didn't see the WARNING overcommit_memory is set to 0! warning, though...

markdorison commented 6 years ago

We recently ran into the vm.overcommit_memory issue. @geerlingguy is this something you would be open to including in this role?

stale[bot] commented 4 years ago

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

stale[bot] commented 4 years ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.