Solved

Linux memory usage

Posted on 2007-04-02
3
274 Views
Last Modified: 2013-12-15
I tried to track down what process was gradually taking up more memory on my web server and came to the conclusion that it was Apache and Mysql.
I have a dedicated server with 2 GB memory, two dual 3GHz Pentium 4 cpu's and a 160 GB SATA HDD.

This server is used to serve dynamic content using a custom web application that I built using php and mysql.
Altogether, I use php, mysql and apache to serve the content. I have finely tuned and tested every aspect of the web application so it does not consume much memory and barely any cpu load. It is very fast and efficient. It is also commercial service that gets several thousand requests a day which is minor for what I expect to get soon. I use cpanel to manage it easier.

Throughout the last 5 days, I did some tests. First, I rebooted the server, then I used TOP and FREE to show process load and memory usage stats. The memory usage started out around 226 MB which appears to be normal, then gradually reached 300 MB by the end of the day. Fast forward 5 days later and the memory gradually reached 1.4 GB of usage. I have monitored it every day and saw it getting higher a day at a time. I did some more tests using TOP and found that mysql and apache appear to be using the most amount of memory. These are the two main programs that get used the most because these are what keeps the web application going. However, I did not expect apache and mysql to keep using more memory every day. It seems like these two servers are not using memory efficiently. I am not sure if this is normal, or if there are settings I need to change in Apache or Mysql's config files that will change the way these two servers manage memory or processes better.

If there is anyone that has experienced a similar situation and found out how to resolve it, I would appreciate some real tips.

If there is anything else you need to know, feel free to ask me.






0
Comment
Question by:ray-solomon
3 Comments
 
LVL 27

Accepted Solution

by:
Nopius earned 250 total points
ID: 18841333
> However, I did not expect apache and mysql to keep using more memory every day. It seems like these two servers are not using memory efficiently.
Be sure, Apache and MySQL use memory as efficiently as it could be ;-)

Most probably your problem is in PHP application that leads apache and mysql to eat more and more memory. So you have memory leaks in a PHP code. PHP itself may have memory leaks in it's internal libraries.
Apache grows because PHP mod_php runs in address space of Apache process.
MySQL process grows, if you, for example, call mysql_connect() without mysql_close().

That is only my suggestion, may be others can help you ...
0
 
LVL 10

Assisted Solution

by:ssvl
ssvl earned 250 total points
ID: 18846787

Note that in Red Hat Enterprise. Linux 3 and earlier, most free memory will be used for cache.
0
 
LVL 10

Author Comment

by:ray-solomon
ID: 18848050
Hi ssvl:
I have apache 1.3.37. From what I read, mod_cache is not available for 1.3.37, so it appears that nothing is being cached, but I am looking into this more. I could be wrong.
I suppose I could upgrade to apache 2.2.4 this weekend, but I am still trying to determine the exact cause first.

I will need to recompile this weekend anyway so I can add mod_info.c to the build.

Hi Nopius:
Thanks for your feedback.

I have done many more tests and I am still testing, and I feel confident it is an Apache config settings issue. After I learn more, I will update this post.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Currently, there is not an RPM package available under the RHEL/Fedora/CentOS distributions that gives you a quick and easy way to allow PHP to interface with Oracle. As a result, I have included a set of instructions on how to do this with minimal …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now