I've installed monit on my server I'm getting following messages quite often, about 10-20/day.
monit alert -- Resource limit matched apache
Resource limit matched Service apache
Date: Fri, 27 May 2011 12:15:41 +0100
Description: total mem amount of 476168kB matches resource limit [total mem amount>358401kB]
Your faithful employee,
# free -m
total used free shared buffers cached
Mem: 1997 1905 91 0 67 1233
-/+ buffers/cache: 604 1393
Swap: 1027 158 868
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 161920 160672 65104 1202396 4 2 509 82 2 8 8 3 77 12 0
Any clue what to look for more and how to solve this memory exhaustion issue?
Is that only 2 Gigs? On a Server? Solve that by adding 8 or 10 gigs.
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.
It's 4 gigs, dedicated server. Total not more than 100k visitors a day, But around 100 of Wordpress blog.
Can add more RAM, provider doesn't allow.
So making Swap file 4gig would help?
Any other recommendations with server settings?
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.
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.
I just checked it and it is 2GB.
And server crashed today. It is becoming pain now.
See previous posts and add resources. I don't doubt the experience behind Johnsfine's comments, but if you head into swap on load, you slow your box with less efficient memory when it is at it's busiest.
Running out of swap doesn't crash a box, btw. I managed that once, and what happened was that the kernel killed off the offending compile (It was pulling some massive executable together with ld)
Also quite often when I get burst of traffic from social media (around lets say 100s of http request in 1-3 secs) it overloads.
Other experts suggest to go for other webservers and not Apache.
|All times are GMT -5. The time now is 02:26 PM.|