Originally Posted by JackJermey
It's 4 gigs, dedicated server.
Then you need to figure out why the output you posted says it is only a 2GB server.
Also, I don't know anything about monit, so consider this next comment only for what it's worth: Why is the trigger for that message set so low? If apache is the primary service you are running, there should be nothing wrong with its using half a GB of your 2GB of ram, plus it is responsible for some unmonitored portion of the 1.2GB of cache use. That all looks OK even in a 2GB server.
Originally Posted by business_kid
The bottom line tells you it's using swap. Heaven help you if it got busy.
It should read 1027 0 1027 (i.e. 0 used and all free)
You should have equal swap as ram, or more to cater for business.
I don't think a server using swap is necessarily bad or unexpected. If the swap stats were 0 used and 1027 free, that would be OK. But that should not be viewed as a goal.
However, swap being used at all should be a reason to rethink whether you have enough swap. Forget any rule you may have heard about swap size relative to ram size. All those rules are useless.
You want a significant margin of error on swap size for a server. If none were ever used, 1GB as both the total and the margin of error should be OK. As soon as even a little swap is used, I think that indicates a 2GB margin of error is more appropriate. Next time you adjust swap size, set it at least
2GB bigger than the most you've ever seen used (so if all you ever saw was that one output from free 2048+158 = 2206MB or more as your new swap size).
With a 2GB or more margin for error, you don't need to regularly check it to see if you really needed even more. But if you happen to notice some time in the future that significantly less than 2GB of swap is free, you might increase swap again or rethink whether physical ram is sufficient. It looks to me like your use is actually OK in just 2GB of physical ram. It doesn't matter much that 158MB of swap is used, and increasing swap to 2206MB or more would be wise but isn't even urgent.
Note that a small use of swap is not
an indication of memory pressure. If a normal load on your 2GB system used 158MB of swap, a naive understanding of swap use would project double that load to use 2316MB of swap (double the 2000MB+158MB memory load and add no physical ram so all the new load lands in swap). But in reality, if you doubled the memory load, your 158MB swap use would likely remain just 158MB. That whole incremental memory load would likely come out of cache, rather than go into swap. The 158MB isn't the beginning of something bigger. It is likely an ordinary very contained effect independent of any memory pressure. The extra 2GB of swap I recommend is there in case of real memory pressure. But I don't expect real memory pressure. It is pure safety margin.