Linux 内存调优的两个重要参数
        注意
      
      本文最后更新于 2025-03-29,文中内容可能已过时。
      今天在看这篇介绍 Linux 性能调优 的博客(Linux Performance: Almost Always Add Swap Space),其中涉及到如何调整内核内存的调整机制。主要的参数有
-  swappiness: This control is used to define how aggressively the kernel will swap memory pages. Higher values will increase aggressiveness; lower values decrease the amount of swap. (default = 60, recommended values between 1 and 60) Remove your swap for 0 value, but it is usually not recommended in most cases.
-  vfs_cache_pressure: Controls the kernel’s tendency to reclaim the memory, which is used for caching of directory and inode objects. (default = 100, recommend value 50 to 200)
我的理解是
-  swappiness: 内核处理 swap 的激进程度。越小代表越不要进行 swap,尽可能把进程都存放在内存。这有利于提升性能。
-  vfs_cache_pressure: 内核回收cache的激进程度。越小代表越不要回收cache,尽可能保留所有的缓存在内存。这有利于提升性能。
一般而言,我们可以这样配置
|  |  | 
 支付宝
支付宝
           微信
微信
          
 william
 william