• swappiness相关知识


    最近工作中频繁遇到swap引发的问题,记得曾经读过当内存比较大的时候可以将swappiness调整成0。下面整理一下swappiness相关的知识。

    1、什么是swap

    Swap空间的作用可简单描述为:当系统的物理内存不够用的时候,就需要将物理内存中的一部分空间释放出来,以供当前运行的程序使用。那些被释放的空间可能来自一些很长时间没有什么操作的程序,这些被释放的空间被临时保存到Swap空间中,等到那些程序要运行时,再从Swap中恢复保存的数据到内存中。这样,系统总是在物理内存不够时,才进行Swap交换。

    2、swappiness干什么用

    swappiness是控制系统使用swap分区的频率阀值,当swappiness=100的时候,系统会积极使用swap分区,而当swappiness=0的时候系统最大限度的有限使用物理内存。

    Swappiness is a property for the Linux kernel that changes the balance between swapping out runtime memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100 inclusive. A low value means the kernel will try to avoid swapping as much as possible where a higher value instead will make the kernel aggressively try to use swap space. The default value is 60, and for most desktop systems, setting it to 100 may affect the overall performance, whereas setting it lower (even 0) may improve interactivity (decreasing response latency.)[1]
    In short:
    vm.swappiness = 0 - it will swap only to avoid an out of memory condition
    vm.swappiness = 60 - default value
    vm.swappiness = 100 - it will swap aggressvely
    To temporarily set the swappiness in Linux, as root you set the value to 100 with the following command: echo 100 > /proc/sys/vm/swappiness
    Permanent changes are made in /etc/sysctl.conf via the following configuration line (inserted if not present previously): vm.swappiness = 100

    3、如何修改swappiness

    查看

    cat /proc/sys/vm/swappiness

    修改

    sysctl vm.swappiness=10

    永久修改

    echo "0" >> /etc/sysctl.conf
  • 相关阅读:
    Global.asax的Application_BeginRequest实现url重写无后缀的代码
    Windows 2008驱动安装失败的原因及解决方法
    解决win8.1电脑无法安装手机驱动问题
    适用于Win8的Office2003_SP3精简版集成各类补丁+兼容包
    CSS 文本缩进,行间距
    自动换行后缩进怎么做(CSS)?(可用于 Li y 元素的排版)
    ApkTool反编译和重新打包
    sql server 2005 32位+64位、企业版+标准版、CD+DVD 下载地址大全
    【Lua】Lua中__index与元表(转)
    【VS2012】项目文件夹管理
  • 原文地址:https://www.cnblogs.com/billyxp/p/2877076.html
Copyright © 2020-2023  润新知