Introduction to Linux Kernel Tuning:                                Kernel Parameters and Their Impact

Introduction to Linux Kernel Tuning: Kernel Parameters and Their Impact

In this final part, we will explore various kernel parameters and their impact on system performance. Adjusting these parameters allows for fine-tuning your Linux system to achieve optimal performance and stability.



Common Kernel Parameters to Tune

Swappiness:

  • What it does: Controls the tendency of the kernel to swap out runtime memory from RAM to the swap space.
  • Default Value: 60
  • Tuning Recommendation: Lower values (e.g., 10) reduce swapping, which can be beneficial for systems with ample RAM.

sudo sysctl vm.swappiness=10        

Anonymous page: dynamic runtime data such as stack and heap

FS (Filesystem) page: Payload such as application data, shared libs etc.


For more details, check out this link : hana systems linux swappiness

File Descriptor Limits:

  • What it does: Sets the maximum number of open file descriptors, impacting the number of files/processes that can be handled simultaneously.
  • Default Value: Varies by distribution
  • Tuning Recommendation: Increase the limit for systems running applications requiring numerous open files.

sudo sysctl fs.file-max=100000        


Dirty Ratio:

  • What it does: Controls the percentage of system memory that can be filled with "dirty" (not yet written to disk) data before the process must write it to the disk.
  • Default Values: vm.dirty_ratio = 40, vm.dirty_background_ratio = 10
  • Tuning Recommendation: Lower values can improve system responsiveness at the cost of more frequent disk writes.

sudo sysctl vm.dirty_ratio=15
sudo sysctl vm.dirty_background_ratio=5        


I/O Scheduler:

  • What it does: Determines how disk I/O operations are managed. Common schedulers include noop, deadline, and cfq.
  • Tuning Recommendation: Select the I/O scheduler based on your workload. For example, noop can be beneficial for SSDs.

echo noop | sudo tee /sys/block/sda/queue/scheduler        


TCP/IP Parameters:

  • What they do: Control various aspects of TCP/IP networking stack behavior.
  • Examples: net.ipv4.tcp_fin_timeout: Time to wait before closing an inactive TCP connection. net.core.netdev_max_backlog: Maximum number of packets allowed in the network device queue.

sudo sysctl net.ipv4.tcp_fin_timeout=30
sudo sysctl net.core.netdev_max_backlog=5000        



Applying and Persisting Kernel Parameters

Applying Changes:

  • Kernel parameters can be set at runtime using the sysctl command as shown above.
  • To apply changes immediately:

sudo sysctl -p        

Persisting Changes:

  • To make changes permanent, add the parameters to the /etc/sysctl.conf file.

sudo nano /etc/sysctl.conf        

  • Add your parameters at the end of the file:

vm.swappiness=10

fs.file-max=100000

vm.dirty_ratio=15

vm.dirty_background_ratio=5

net.ipv4.tcp_fin_timeout=30

net.core.netdev_max_backlog=5000        

  • Save and exit the editor.


Conclusion

By understanding and tuning kernel parameters, you can significantly enhance the performance and stability of your Linux system. Adjusting parameters like swappiness, file descriptor limits, and I/O schedulers allows for a tailored approach to system optimization.

Key points covered:

  • Swappiness and Memory Management: Reducing swappiness can improve performance by minimizing swapping.
  • File Descriptor Limits: Increasing limits allows for better handling of numerous open files.
  • Dirty Ratio and I/O Schedulers: Tuning these can improve system responsiveness and disk I/O performance.
  • TCP/IP Parameters: Optimizing these can enhance network performance.

With these tuning techniques, you can achieve a more efficient and responsive Linux system. Always test changes in a controlled environment before applying them to production systems.

Stay tuned for more Linux performance tuning and system optimization tips!

?

要查看或添加评论,请登录

Hosni Zaaraoui的更多文章

社区洞察

其他会员也浏览了