Solved

Linux memory usage

Posted on 2007-04-02
3
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

695 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