Kernel Tunables

There are so many random “Allinone optimization” bash scripts out there that the maker of them probably only knows half of the meaning of those tunable values. Everything that could “Optimize” anything in Linux should be based on your services that are hosted on the target servers.

So I am writing this down just in case I forgot what all of these things mean and have to look through the internet and blogs all over again.

KENEL TUNABLES

> net.ipv4.tcp_r/wmem

This variable effect Linux minimum, default, maximum send and receive buffer (aka Linux kernel’s skb), the preset value is 4096 87380 6291456.

If a program has a preset SO_RCVBUF value then this kernel variable would be ignored.

the default value of this variable will not override net.core.r/wmem_max but will override net.core.r/wmem_default.

> net.core.r/wmem

Kinda the same as the variable mentioned above but globally.

The buffer size should not be set too high blindly or it would cause network bufferbloat, increase the latency of receiving/sending packets, and suck up all the RAM that you have.

It should be set correctly based on the BDP( Buffer size = Bandwidth (bits/s) * RTT (seconds) ) of the production environment.

> net.ipv4.tcp_syncookies

oh boy oh boy. DO NOT ENABLE THIS TUNABLE IN ANY CASE.

If this tunable is enabled, all the TCP options including backlogs will be ignored.

Do not follow some blog posts that enable this tunable for “Security” reasons.

> net.core.somaxconn

Setting this tunable to a higher value could prevent packet dropping if encountering network traffic bursts. But if the backend’s computing performance could not catch up, setting this tunable to a higher value could have worse performance than the default. (Should have to reroute the request to the other backends to handle instead of keeping all the requests waiting for this busy backend)

> net.ipv4.tcp_window_scaling

Enable this tunable to have a bigger broadcast receiving window size.

Linux optimization is not only limited to some simple kernel tunable tweaks. Drivers/NICs/CCA are all relatively important. I might post another blog about CCA tweaking.