====== Linux Kernel-Tuning ====== ===== BBR Congestion Control Algorithm ===== BBR is included since Linux 4.10. It won't show in net.ipv4.tcp_allowed_congestion_control or net.ipv4.tcp_available_congestion_control if the module tcp_bbr isn't loaded. This module is loaded automatically if activate bbr. Check the current algorithm. # sysctl net.ipv4.tcp_congestion_control net.ipv4.tcp_congestion_control = bbr Switch to bbr. sysctl -w net.ipv4.tcp_congestion_control=bbr Permanently activate bbr. echo "net.ipv4.tcp_congestion_control = bbr" > /etc/sysctl.d/90-bbr.conf **Additional Information** You will find a lot of instructions which set "net.core.default_qdisc" to "fq". The reason is, the first implementation was specifically designed for fq and you can still find references in the source code: > NOTE: BBR might be used with the fq qdisc ("man tc-fq") with pacing enabled, otherwise TCP stack falls back to an internal pacing using one high resolution timer per TCP socket and may use more resources. -- [[https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ipv4/tcp_bbr.c|tcp_bbr.c]] According to the official documentation, BBR doesn't require fq anymore. It also works with fq_codel for example. >This means that there is no longer a strict requirement to install the "fq" qdisc to use BBR. Any qdisc will work, though "fq" performs better for highly-loaded servers. -- [[https://github.com/google/bbr/blob/master/Documentation/bbr-quick-start.md|TCP BBR Quick-Start: Building and Running TCP BBR on Google Compute Engine]] **Links** * [[https://github.com/google/bbr|Github: BBR]] * [[https://cloud.google.com/blog/products/networking/tcp-bbr-congestion-control-comes-to-gcp-your-internet-just-got-faster|TCP BBR congestion control comes to GCP – your Internet just got faster]] ===== FQ - Fair Queue traffic policing ===== FQ (sometimes referred to as sch_fq because of the name of its kernel module name) is a packet scheduler which was implemented by Eric Dumazet like FQ_Codel and can be configured as queueing discipline (qdisc). FQ can be used as a drop in replacement for pfifo_fast. The CoDel wiki says this: >For servers with tcp-heavy workloads, particularly at 10GigE speeds, for queue management, we recomend sch_fq instead of fq_codel as of linux 3.12. -- [[https://www.bufferbloat.net/projects/codel/wiki/|CoDel Overview]] * fq_codel - best for routers, hypervisors and best general purpose qdisc * fq - best for fat servers Activate on the current system and replace qdisc on eth0 (not recommended). sysctl -w net.core.default_qdisc=fq tc qdisc replace dev eth0 root fq Persistent configuration. Reboot required to activate (recommended). echo "net.core.default_qdisc = fq" > /etc/sysctl.d/90-fq.conf **Links** * man 8 tc-fq * [[https://github.com/torvalds/linux/blob/master/net/sched/sch_fq_codel.c|sch_fq_codel.c]] ===== Ephemeral Ports ===== sysctl -w net.ipv4.ip_local_port_range="1024 65000" Permanently set this configuration. echo "net.ipv4.ip_local_port_range = 1024 65000" > /etc/sysctl.d/90-ephemeral_ports.conf **Links** * [[https://www.nginx.com/blog/tuning-nginx/|Tuning NGINX for Performance]] * [[https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html|IP sysctl]]