Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Just so you're clear, according to the values you have provided your server starts out taking up 6MB of memory and end the day with around ~28MB of memory. That is not very much and not abnormal. So there really isn't anything you should worry about. Some of the high availability web servers I run take up several gigabytes in memory and still run just fine.
So worry not.
Another thing I'd like to note, you didn't provide very much information. We don't know the specs of your server nor the normal load you expect it to handle (i.e. requests per second or connections daily). And that generic output of what appears to be a stack trace is non-descriptive either. What commands did you use to obtain that information besides catting a temporary file? The only reason why I gave you the values I did is because of what you originally stated ("~28544 bytes") when your catted file states the measurements are in "Total kB". Details like that matter when analyzing your own performance.
So lack of information, plus lack of explanation, make it so that nobody on this forum could give you a concise answer to your perceived problem or even begin to point you in the right direction.
Thanks and sorry for the lack of information, I thought that the presented would be sufficient. I'm always afraid that vast details detract paying attention to the problem. I have edited the bytes/kilobytes typo too.
The load on the server is relatively low. The VPS instance is a micro EC2: 2 ECUs (bursting), 613 MB RAM, low I/O performance. The LAMP environment is Apache httpd 2.2 (prefork, mod_ruid2), php 5.3 (mod_php DSO), mysql 5.1, latest stable Wordpress. No opcode caching of course.
I have tuned the LAMP environment to utilize only the necessary memory. The temporary files have 'pmap', 'before_restart' and 'after_restart' in their names suggesting that I have used the pmap command to get the output (pmap -x httpd_child_PID) before and after 'service httpd restart' :-)
I am interested in why httpd child processes increases memory utilization over time, but I supose that it's not a straight forward answer?
What version of httpd are you using and what modules do you have currently enabled? Are there modules which you don't need that can be disabled? The reason why I ask is sometimes there can be a memory leak in a given module which httpd can't do anything about. I found this bug report with a work around as an example of a module which leaks memory.
Why are you investigating the memory utilization of httpd? Are you currently experiencing performance problems due to it or is this more of a personal exercise? Either way it's fine. If you need to have the server restart every once in a while then perhaps writing a script and running it in a subshell to check memory and when memory is low to restart apache to free up memory would be a possible (hacked) solution.
You could also try tweaking httpd.conf to limit its ability to grab resources.
While there's not a clear answer to what is currently causing your problem (whether it's the http application you're using or httpd itself), there are steps you can take which will help the management of your memory.
Are there any errors in your logs indicating what could be the problem? For instance too many open file descriptors, etc.?
Another thing you can do is to write your own "monitoring script" which monitors the memory usage of httpd throughout the day. By doing that you'll be able to see when it starts eating memory and check the logs during that time to see what's happening. You may have to set the log level to debug for more verbose log output. An example script to monitor the memory for httpd would be something like this. I made it easy for you to change the user and the process name to whatever you want.
OK, I got the culprit - it was PHP DSO and wordpress that used the extra memory.
I have tried a few experiments with PHP's memory_get_usage() function and concluded that when I hit the wordpress PHP page it would instantly increase httpd's memory for about 18MB. It didn't increase over time actually. So, no memory leaks, just normal behaviour that I didn't notice as I was hitting some static HTML tests before that.
sag47, thanks for all the comments and recommendations. This was all just for my curiosity, and I hope this thread will also help someone else :-)
No problem, exercises are fun and encouraged which is basically why I was throwing scenarios and solutions left and right. It's good to want to learn
I fixed the httpd monitoring script to account for forking httpd processes. I also added an interpreter comment and some other misc environment information for the conditions in which I successfully tested the script.
FYI if you use vim I inserted environment info like this in normal mode...