Linux memory usage
Posted on 2007-04-02
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.