The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Is swapping bad to hard drives lifetime ?

Discussion in 'Workarounds and Optimization' started by Smaily, Jul 19, 2013.

  1. Smaily

    Smaily Well-Known Member

    Joined:
    Sep 19, 2011
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    I've heard from somewhere that if server is using swapping constantly then eventually you have to buy new hard drives because they get killed off like that.

    So I have,
    Total processors: 8 (2xQuad core Intel(R) Xeon(R) CPU E5405 @ 2.00GHz)
    RAM: 32GB (16x2GB)
    Interface is running bond mode 6.
    Plenty of hard drives to cover 12TB of Disk Space in Raid 0 (4x4TB)

    I have found few threads about swapping and read them through.
    http://forums.cpanel.net/f34/memory-usage-apparently-higher-than-expected-308861.html#post1277421
    performance - Why use swap when there is more than enough RAM - Unix & Linux Stack Exchange
    Linux: Should You Use Twice the Amount of Ram as Swap Space?
    http://www.chrisjohnston.org/ubuntu/why-on-linux-am-i-seeing-so-much-ram-usage

    However in my case when RAM usage reaches up to 20-25% it starts to use swap. But seriously isn't it more healthyer for server to use purely RAM without swapping? Also there is no way whatsoever to clear swap using without restarting the server. RAM usage seems to be more safe.

    I have Linux system and if I would switch default that is about 3/4 of system ram in use or more equals swap usage - Into some less swap usage like 0.5 instead of 0.6 meybe? I've heard it's not good to zerofy swap usage out either because then RAM usage goes twice as high immediately.

    #cat /proc/swaps
    Code:
    Filename                                Type            Size    Used    Priority
    /dev/dm-1                               partition       4063224 0       -1
    
    #swapon -s
    Code:
    Filename                                Type            Size    Used    Priority
    /dev/dm-1                               partition       4063224 0       -1
    # free -m
    Code:
                 total       used       free     shared    buffers     cached
    Mem:         32112      11029      21082          0        411       4093
    -/+ buffers/cache:       6525      25587
    Swap:         3967          0       3967
    # top
    Code:
    top - 01:24:17 up 4 days,  7:00,  1 user,  load average: 0.22, 0.15, 0.15
    Tasks: 364 total,   1 running, 361 sleeping,   0 stopped,   2 zombie
    Cpu0  :  1.0%us,  0.5%sy,  0.0%ni, 98.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Cpu1  :  1.0%us,  1.0%sy,  0.0%ni, 98.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Cpu2  :  3.4%us,  1.5%sy,  0.0%ni, 95.1%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Cpu3  :  2.0%us,  1.0%sy,  0.0%ni, 97.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Cpu4  :  0.5%us,  0.5%sy,  0.0%ni, 99.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Cpu5  :  1.0%us,  0.5%sy,  0.0%ni, 98.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Cpu6  :  0.5%us,  0.5%sy,  0.0%ni, 99.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Cpu7  :  3.9%us,  1.5%sy,  0.0%ni, 94.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Mem:  32883272k total, 11302132k used, 21581140k free,   421148k buffers
    Swap:  4063224k total,        0k used,  4063224k free,  4191768k cached
    
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
        4 root      20   0     0    0    0 S 11.9  0.0 533:48.61 [ksoftirqd/0]
        9 root      20   0     0    0    0 S  4.9  0.0 310:44.05 [ksoftirqd/1]
       13 root      20   0     0    0    0 S  4.5  0.0 163:19.83 [ksoftirqd/2]
       29 root      20   0     0    0    0 S  2.5  0.0  63:10.00 [ksoftirqd/6]
       33 root      20   0     0    0    0 S  2.0  0.0  60:08.67 [ksoftirqd/7]
     6075 nobody    20   0  163m  57m 3256 S  2.0  0.2   0:10.61 /usr/local/apache/bin/httpd -k
     5140 nobody    20   0  163m  58m 3452 S  1.5  0.2   0:12.20 /usr/local/apache/bin/httpd -k
    17214 root      20   0 15308 1468  948 R  1.0  0.0   0:00.05 top
     1407 root      20   0  150m  15m 1460 S  0.5  0.0   0:04.39 lfd - sleeping
     1726 root      20   0     0    0    0 S  0.5  0.0   0:51.57 [bond0]
    16908 mailnull  20   0  301m  79m 4316 S  0.5  0.2   0:02.31 MailScanner: waiting for messa
    
    # cat /proc/meminfo
    Code:
    MemTotal:       32883272 kB
    MemFree:        21590552 kB
    Buffers:          421168 kB
    Cached:          4192168 kB
    SwapCached:            0 kB
    Active:          9768000 kB
    Inactive:         621904 kB
    Active(anon):    5776872 kB
    Inactive(anon):       32 kB
    Active(file):    3991128 kB
    Inactive(file):   621872 kB
    Unevictable:           0 kB
    Mlocked:               0 kB
    SwapTotal:       4063224 kB
    SwapFree:        4063224 kB
    Dirty:               680 kB
    Writeback:             0 kB
    AnonPages:       5776576 kB
    Mapped:            30984 kB
    Shmem:               372 kB
    Slab:             494144 kB
    SReclaimable:     390960 kB
    SUnreclaim:       103184 kB
    KernelStack:        3376 kB
    PageTables:        54896 kB
    NFS_Unstable:          0 kB
    Bounce:                0 kB
    WritebackTmp:          0 kB
    CommitLimit:    20504860 kB
    Committed_AS:    8807312 kB
    VmallocTotal:   34359738367 kB
    VmallocUsed:      104408 kB
    VmallocChunk:   34359591104 kB
    HardwareCorrupted:     0 kB
    AnonHugePages:   3201024 kB
    HugePages_Total:       0
    HugePages_Free:        0
    HugePages_Rsvd:        0
    HugePages_Surp:        0
    Hugepagesize:       2048 kB
    DirectMap4k:        7488 kB
    DirectMap2M:    33546240 kB
    
    Where, in which files in Linux can swap limits be changed?

    # locate swap
    Code:
    /home/.cpanm/work/1373665143.30705/BSD-Resource-1.2906/blib/lib/auto/BSD/Resource/nswap.al
    /home/.cpanm/work/1373810466.27407/BSD-Resource-1.2907/blib/lib/auto/BSD/Resource/nswap.al
    /home/virtfs/cf/sbin/mkswap
    /home/virtfs/cf/sbin/swapoff
    /home/virtfs/cf/sbin/swapon
    /sbin/mkswap
    /sbin/swapoff
    /sbin/swapon
    /usr/include/byteswap.h
    /usr/include/bits/byteswap.h
    /usr/include/sys/swap.h
    /usr/lib/anaconda/iw/upgrade_swap_gui.py
    /usr/lib/anaconda/iw/upgrade_swap_gui.pyc
    /usr/lib/anaconda/iw/upgrade_swap_gui.pyo
    /usr/lib/anaconda/storage/devicelibs/swap.py
    /usr/lib/anaconda/storage/devicelibs/swap.pyc
    /usr/lib/anaconda/storage/devicelibs/swap.pyo
    /usr/lib/anaconda/storage/formats/swap.py
    /usr/lib/anaconda/storage/formats/swap.pyc
    /usr/lib/anaconda/storage/formats/swap.pyo
    /usr/lib64/perl5/bits/byteswap.ph
    /usr/lib64/pm-utils/bin/pm-reset-swap
    /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/cpanel_lib/x86_64-linux-64int/auto/BSD/Resource/nswap.al
    /usr/local/cpanel/bin/swapip
    /usr/local/cpanel/perl/BSD/Resource/nswap.al
    /usr/local/lib64/perl5/auto/BSD/Resource/nswap.al
    /usr/share/doc/db4-devel-4.7.25/api_c/db_get_byteswapped.html
    /usr/share/doc/db4-devel-4.7.25/api_cxx/db_get_byteswapped.html
    /usr/share/doc/db4-devel-4.7.25/api_tcl/db_is_byteswapped.html
    /usr/share/doc/db4-devel-4.7.25/ref/upgrade.3.3/getswap.html
    /usr/share/man/man2/swapcontext.2.gz
    /usr/share/man/man2/swapoff.2.gz
    /usr/share/man/man2/swapon.2.gz
    /usr/share/man/man3/BN_swap.3ssl.gz
    /usr/share/man/man3/swapcontext.3.gz
    /usr/share/man/man3p/swapcontext.3p.gz
    /usr/share/man/man8/mkswap.8.gz
    /usr/share/man/man8/swapoff.8.gz
    /usr/share/man/man8/swapon.8.gz
    /usr/share/vim/vim72/macros/swapmous.vim
     
    #1 Smaily, Jul 19, 2013
    Last edited: Jul 19, 2013
  2. ilaurens

    ilaurens Active Member

    Joined:
    Jul 13, 2013
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hallo,

    Swapping does not kill your harddisk(non-ssd), Swapping will take a lot of speed away from your harddisk and even make it slower because harddisk is way slower than memory. It is bad for ssd though since swapping relies a lot on write and SSD is write limited.

    Swapping could be avoided, it's a last resort before crashing, if it start to swap with 25% memory usage, something is wrong. I suggest you to take action to solve that problem.
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    671
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Are you experiencing any other issues on the server besides the swapping? For instance, is your load high, or is there high disk I/O? You could disable SWAP if necessary, but it's purpose is to help prevent your server from running out of memory. The following external document is useful:

    All About Linux SWAP Space

    Thank you.
     
  4. Smaily

    Smaily Well-Known Member

    Joined:
    Sep 19, 2011
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Load went high as 7-8 aswell, yes. Couldnt notice anything that could have caused it.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    671
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page