Back to tools

sysctl.conf Optimizer

About sysctl

sysctl is a utility for modifying Linux kernel parameters at runtime. The parameters are located in /proc/sys/ and can be configured in /etc/sysctl.conf.

This tool generates a configuration for /etc/sysctl.d/99-tuning.conf that you can apply with:


sudo sysctl -p /etc/sysctl.d/99-tuning.conf
              

Kernel Tuning by Server Type

Linux kernel optimization is not universal — each server type requires specific adjustments to maximize performance. A web server handling thousands of concurrent connections needs very different TCP parameters from a database server prioritizing disk I/O speed or a file server with large transfers.

Web server (Nginx/Apache): Prioritizes ephemeral connection handling with net.ipv4.tcp_tw_reuse=1, net.core.somaxconn=65535 for listen queues, and net.ipv4.tcp_keepalive_time=60 to quickly detect dead connections. High listen backlog prevents connection rejections during traffic spikes.

Database (PostgreSQL/MySQL/MariaDB): Reduce vm.swappiness=1 or 10 to minimize swap, adjust vm.dirty_ratio=20 and vm.dirty_background_ratio=5 for more frequent synchronous writes. The page cache should stay hot for repetitive queries.

File server (Samba/NFS): Increase vm.dirty_ratio=40 and vm.dirty_background_ratio=15 to buffer large writes. Raise net.ipv4.tcp_wmem and net.core.wmem_default for large file transfers. With BBR as the congestion algorithm, long transfers benefit from more aggressive bandwidth probing.

Frequently Asked Questions

What is sysctl and how is it used for Linux kernel tuning?

sysctl is a Linux utility that allows modifying kernel parameters at runtime without recompiling. Parameters are located in /proc/sys/ and can be permanently configured in /etc/sysctl.conf or files in /etc/sysctl.d/. It enables optimization of network, memory, security, and overall system performance.

Which sysctl parameters improve network performance?

Key parameters include: net.core.rmem_max and net.core.wmem_max for network buffers, net.ipv4.tcp_congestion_control for congestion algorithms (bbr, cubic), net.ipv4.tcp_slow_start_after_idle for maintaining speed on persistent connections, and net.core.netdev_max_backlog for input queues. Properly adjusting these can dramatically improve TCP throughput.

How to apply sysctl changes without rebooting?

Apply changes immediately with "sudo sysctl -p /etc/sysctl.d/99-tuning.conf". You can also use "sudo sysctl -w parameter=value" to change a specific parameter on the fly. To verify current values, use "sysctl parameter.name" or "cat /proc/sys/path/to/parameter".

Which sysctl parameters improve server security?

For security: net.ipv4.conf.all.rp_filter=1 (IP spoofing protection), net.ipv4.tcp_syncookies=1 (SYN flood protection), net.ipv4.conf.all.accept_source_route=0 (disable source routing), kernel.kptr_restrict=1 and kernel.dmesg_restrict=1 (restrict kernel info), and net.ipv4.icmp_echo_ignore_broadcasts=1 (prevent Smurf attacks).

What is TCP BBR and how to enable it with sysctl?

TCP BBR (Bottleneck Bandwidth and Round-trip propagation time) is a congestion control algorithm developed by Google that maximizes TCP throughput. Enable it with "net.ipv4.tcp_congestion_control=bbr". BBR is especially effective on connections with packet loss or high RTT, outperforming Cubic in many scenarios.

How to optimize system memory with sysctl?

Key parameters: vm.swappiness=10 to reduce swap usage (better performance on servers with sufficient RAM), vm.vfs_cache_pressure=50 to preserve inode/dentry cache, vm.dirty_ratio=30 and vm.dirty_background_ratio=10 for disk write optimization, and vm.overcommit_memory=1 for better memory management in RAM-intensive applications.