This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

When should I worry about swap usage?

I've installed two new ASG 220s with HA, IPS, and web and email security on.  For the first few days RAM hovered around 65% with no swap usage.  About 5 days in swap usage suddenly jumped to 10%.  About a week later swap jumped to 20%.  3 days later takes us to today, and my swap usage has jumped to 30%.  Over this time RAM usage has been fairly stable, hovering in the mid to high 60s and occasionally hitting low 70s.

Should I be worried about the increase in swap usage?


This thread was automatically locked due to age.
Parents
  • Look at the 'Management >> High Availability' 'System Status' tab to see the info about the Slave.  If one gets up above 50%, I'd consider rebooting it.

    How many IPs are covered by this setup.  Are you in Cluster or Hot-Standby mode?

    Cheers - Bob
     
    Sophos UTM Community Moderator
    Sophos Certified Architect - UTM
    Sophos Certified Engineer - XG
    Gold Solution Partner since 2005
    MediaSoft, Inc. USA
  • There is an interesting point i'd like to make, about a common misconception with Astaro and the Swap usage. Swap is disk space emulated as memory when memory becomes consumed. Of course during ACTUAL swap usage during a time of need, performance will be affected as hard drives not only are vastly slower than memory, but swap will access it quickly causing the HDD to be kept quite busy, thus increasing waits and other loads for applications (like logging or reporting) that need access to the HDD.

    The misconception is around rebooting the device when swap "grows". The way linux handles the swap space is that it will be allocated, and yes it may grow during subsequent swapping times when needed, but Linux is very greedy and doesn't like to give back disk space allocated as swap very often when it no longer needs it. It's thinking is like "here's a nice piece of HDD space i know how to use, ill just keep it to myself in case i need it again later in the future". Hence over time, your swap usage on the chart may grow, even though at the time while say 800MB has been allocated to swap (and thus shows on the chart) it isnt actively being used, nor causing any load or other errrors. As such, while rebooting will clear the allocation yes, it really offers no direct benefit other than starting the collection/allocation process again. 

    While not underscoring my points above, this is a decent article if you have questions about swapping... Understanding swap files in Linux - Distilled Brilliance

    Hope this might clear up a daily/weekly reboot for no other reason than to show the swap graphs as none [;)]
Reply
  • There is an interesting point i'd like to make, about a common misconception with Astaro and the Swap usage. Swap is disk space emulated as memory when memory becomes consumed. Of course during ACTUAL swap usage during a time of need, performance will be affected as hard drives not only are vastly slower than memory, but swap will access it quickly causing the HDD to be kept quite busy, thus increasing waits and other loads for applications (like logging or reporting) that need access to the HDD.

    The misconception is around rebooting the device when swap "grows". The way linux handles the swap space is that it will be allocated, and yes it may grow during subsequent swapping times when needed, but Linux is very greedy and doesn't like to give back disk space allocated as swap very often when it no longer needs it. It's thinking is like "here's a nice piece of HDD space i know how to use, ill just keep it to myself in case i need it again later in the future". Hence over time, your swap usage on the chart may grow, even though at the time while say 800MB has been allocated to swap (and thus shows on the chart) it isnt actively being used, nor causing any load or other errrors. As such, while rebooting will clear the allocation yes, it really offers no direct benefit other than starting the collection/allocation process again. 

    While not underscoring my points above, this is a decent article if you have questions about swapping... Understanding swap files in Linux - Distilled Brilliance

    Hope this might clear up a daily/weekly reboot for no other reason than to show the swap graphs as none [;)]
Children
  • Agreed, Angelo, but I'm concerned that he seems to have the devices heavily loaded.  Don't you think that if the swap usage jumps right back to 50%, it's a sign that he needs to tune his installation?

    Cheers - Bob
     
    Sophos UTM Community Moderator
    Sophos Certified Architect - UTM
    Sophos Certified Engineer - XG
    Gold Solution Partner since 2005
    MediaSoft, Inc. USA
  • could be, however sometimes this is also caused by the box only actually swapping around the 2am maintenance, that would be something to check as well...to determine when swapping was actually happening, check the memory graphs for when it has consumed all memory, since from there swapping will occur...
  • when i setup my Linux boxes they DON'T SWAP.  swap is used disk for when memory is low or out..and frankly a Linux box should never swap.  

    7.*** is set to have a predilection to swap instead of releasing cached ram...so when the kernel needs ram from the file cache for a program it doesn't release the cache and therefore has to dig into swap.  This is not a proper behavior.  You want the physical ram to be as close to exhausted as possible BEFORE it digs into swap...astaro v7 right now has the vm.swappiness at 60.  I tune this to zero.  This alone will reduce your swap usage by a ton.  If you are still swapping more than 20% after that you need to either turn off features, or upgrade your units ram or replace them beffier ones.

    Owner:  Emmanuel Technology Consulting

    http://etc-md.com

    Former Sophos SG(Astaro) advocate/researcher/Silver Partner

    PfSense w/Suricata, ntopng, 

    Other addons to follow

  • William, what's the trick to turning down the proclivity to swap?
     
    Sophos UTM Community Moderator
    Sophos Certified Architect - UTM
    Sophos Certified Engineer - XG
    Gold Solution Partner since 2005
    MediaSoft, Inc. USA
  • Astaro swaps when it needs to, and not unnecessarily. You wouldn't want to turn down the ability for it to use swap space when needed. Swap space should only be a concern when physical memory usage is very high, and astaro is forced to swap when it otherwise would not.
  • William, what's the trick to turning down the proclivity to swap?


    The recommended way is to use 'sysctl', e.g.
    sysctl vm.swappiness=0

    sysctl swappiness - Google Search

    There's usually a way to make that permanent across reboots.

    You should make sure you have enough RAM before messing with that, btw.

    Barry
  • AngeloC, thanks, it's helpful to understand what the graphs are really detailing. 

    I think as has been suggested I'll reboot to bring the graph down to 0 and then start watching the daily memory usage to determine at what times high memory usage leads to swap increase.

    Josh
  • Astaro swaps when it needs to, and not unnecessarily. You wouldn't want to turn down the ability for it to use swap space when needed. Swap space should only be a concern when physical memory usage is very high, and astaro is forced to swap when it otherwise would not.


    incorrect.  swappiness simply says how greedy it is with physical ram.  Right now the kernel tries to NEVER let anything new into ram and therefore starts digging into swap much sooner than it should.  performance is not hurt by turning vm.swappiness to zero..it actually improves it due to the system NOT having to heade to the hard disk as ram(which we all know that nonseconds access in ram is much better than microsends in hdd).  I have tested this theory on many systems and have yet to find this to be factually incorrect.

    Owner:  Emmanuel Technology Consulting

    http://etc-md.com

    Former Sophos SG(Astaro) advocate/researcher/Silver Partner

    PfSense w/Suricata, ntopng, 

    Other addons to follow