Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2006
    Posts
    185

    Swap memory question

    Hi,

    I have configured 4 GB swap on my server, but it is never used. When I check at /proc/meminfo it always show as 0 used.

    Am I missing some thing here? Please help.

  2. #2
    Join Date
    Apr 2006
    Location
    Southern California
    Posts
    1,125
    As long as you have plenty of RAM, everything should go directly into it. Linux doesn't go into swap unless it's out of RAM.
    Sarcasm, the 6th Ponyman of the Apocalypse.
    Please do not inquire about Tim, the 5th Ponyman.

  3. #3
    Join Date
    Jun 2006
    Location
    Ahh' UnderPants
    Posts
    1,012
    Swap will be used when your RAM is all consumed. If you never reach your RAM limits your swap remains untouched, No worries its very normal. Maybe when you grow traffic swap will be used and will be highly helpful.



  4. #4
    Join Date
    Nov 2006
    Posts
    185
    The problem is I have checked my other servers and all of them are using SWAP space and those have enough memory too. The customer is complaining his server is slow. I just wondered that, is this anything to do with slowness?

  5. #5
    Join Date
    Apr 2006
    Location
    Southern California
    Posts
    1,125
    There's plenty else to slow the server down. Is mySQL and PHP cached? is the site making a massive amount of HD access? As far as performances go, swap slow down things, it would be a problem if you're using a massive amount of swap. Your memory management is as optimized as possible if everything's in RAM.
    Sarcasm, the 6th Ponyman of the Apocalypse.
    Please do not inquire about Tim, the 5th Ponyman.

  6. #6
    There are three simple checks related to swap:
    1. make sure your swap partition is mounted (swapon -s under linux)
    2. make sure your swap is non-zero size - see SwapTotal and SwapFree parameters in /proc/meminfo
    3. check /proc/sys/vm/swappiness - it should be > 0


    As for server speed - website speed depends on lots of factors, from numbers of concurrent connections and memory size to SQL query speed.
    I recomend to do some profiling for your top web pages.
    Search tutorial collection Look4docs.com (Linux, PHP, MySQL, Java and more)

  7. #7
    Actually Linux will go into swap before all RAM is fully consumed. Usually after your RAM usage is >30ish % (determined by swapiness parameter), Linux may decide to swap out unfrequently used pages in favour for file cache to improve the general performance of the system. If your swappiness value is too low, then the swapping does not occur as frequently.

  8. #8
    Join Date
    Nov 2006
    Posts
    185
    Thank you guys. I am monitoring this server and swap is never used. I checked the value at /proc/sys/vm/swappiness and it shows 50. What is it mean? How can I change the value? Please help.

    thank you
    koppan

  9. #9
    swappiness = 0 gives you the behaviour of trying not to swap unless necessary, such as being out of physical memory (RAM)
    swappiness = 100 tells the kernel swap whenever the kernel feels like it
    swappiness = 50 gives you the in-between behaviour.

    In short, the higher the swappiness, the more it will swap.

    ex. to set swapiness to 100:
    Code:
    echo 100 > /proc/sys/vm/swappiness

  10. #10
    Quote Originally Posted by koppan
    I checked the value at /proc/sys/vm/swappiness and it shows 50. What is it mean?
    This is default value. Kernel will swap out rarely used pages so free memory can be effectively used for disk caching (boost performance a lot) or by active processes.

    Too big value (70 and more) can slow down a server because of lots of IO request to/from swap.
    Zero value will force kernel to keep rarely used pages in memory and make it dirty.
    Last edited by astellar; 12-14-2006 at 10:50 PM.
    Search tutorial collection Look4docs.com (Linux, PHP, MySQL, Java and more)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •