LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 05-27-2011, 06:59 AM   #1
JackJermey
LQ Newbie
 
Registered: Feb 2011
Posts: 13

Rep: Reputation: 0
Memory problem


Hi All,
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
Action: alert
Host:
Description: total mem amount of 476168kB matches resource limit [total mem amount>358401kB]

Your faithful employee,
Monit


Memory usage
# free -m
total used free shared buffers cached
Mem: 1997 1905 91 0 67 1233
-/+ buffers/cache: 604 1393
Swap: 1027 158 868



# vmstat
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

Server Settings
Timeout 30
TraceEnable On
ServerSignature Off
ServerTokens Full
FileETag All
StartServers 10
<IfModule prefork.c>
MinSpareServers 5
MaxSpareServers 15
</IfModule>

MaxClients 150
MaxRequestsPerChild 10000
KeepAlive On
KeepAliveTimeout 2
MaxKeepAliveRequests 100

Any clue what to look for more and how to solve this memory exhaustion issue?
 
Old 05-27-2011, 11:40 AM   #2
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,373

Rep: Reputation: 557Reputation: 557Reputation: 557Reputation: 557Reputation: 557Reputation: 557
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.

Last edited by business_kid; 05-27-2011 at 11:42 AM.
 
Old 05-27-2011, 11:52 AM   #3
JackJermey
LQ Newbie
 
Registered: Feb 2011
Posts: 13

Original Poster
Rep: Reputation: 0
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?
 
Old 05-27-2011, 12:04 PM   #4
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,083

Rep: Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110
Quote:
Originally Posted by JackJermey View Post
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.

Quote:
Originally Posted by business_kid View Post
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.

Last edited by johnsfine; 05-27-2011 at 12:36 PM.
 
Old 06-02-2011, 10:12 AM   #5
JackJermey
LQ Newbie
 
Registered: Feb 2011
Posts: 13

Original Poster
Rep: Reputation: 0
I just checked it and it is 2GB.

And server crashed today. It is becoming pain now.
 
Old 06-03-2011, 03:51 AM   #6
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,373

Rep: Reputation: 557Reputation: 557Reputation: 557Reputation: 557Reputation: 557Reputation: 557
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)
 
Old 06-03-2011, 04:14 AM   #7
JackJermey
LQ Newbie
 
Registered: Feb 2011
Posts: 13

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by business_kid View Post
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)
Yes I'm already getting a brand new powerful server. I had close look at the logs and found that there are too many connections (http) when server either overloads or crashes.

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.
 
  


Reply

Tags
memory


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux shared memory segment access problem and x86 Virtual Memory layout. regmee Linux - Kernel 1 08-23-2008 12:11 AM
Difference between resident memory,shared memory and virtual memory in system monitor mathimca05 Linux - Newbie 1 11-11-2007 04:05 AM
The memory problem Gins Linux - General 18 10-18-2005 12:19 PM
Memory problem Nulaxor Linux - General 2 07-16-2003 10:03 AM
Help!?! RH 8 Memory Mapping -High Memory-Virtural Memory issues.. Merlin53 Linux - Hardware 2 06-18-2003 04:48 PM


All times are GMT -5. The time now is 10:56 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration