Centos – High RAM usage by Apache without any visitors

apache-2.2centoshttpdmemoryMySQL

I have recently bought a VPS server with the below configuration

  • Centos 6 64bit
  • 20GB SSD
  • 512MB RAM
  • 512 VSwap

I have hosted around 10 websites. In that 4 of them is WordPress. Others are dynamic(PHP) websites. I have a very few visitors. But when I checked the RAM I found that Apache is most of the ram. When apache is running, ram usage is around 97%. While stopping apache, it becomes 30%.

How can I configure apache so that it uses less ram?

enter image description here

I heard that converting InnoDB to MyISAM can solve ram usage. But my MySQL is only using less ram

Best Answer

In my case, I had Apache with mod_php running on a Centos 64bit VM with 2GB RAM. When I initially installed Apache 2.4, everything worked well and the parent Apache process (owned by root) would consume around 10 MB of memory.

Later on, when I checked top, the parent and all child processes were consuming 28% of server memory (around 500 MB each). After fiddling around with many settings and mpm forks and max servers and what not, I finally did yum remove php and restarted Apache. Memory consumption went back to normal 10 MB. This lead me to believe it was a PHP setting causing the problem. So I copied over php.ini from another server and reinstalled PHP (using yum install php) and again everything worked fine. Comparing the two php.ini files, I found that I had earlier linked browscap in php.ini and it was a 60 MB file which would load in memory during startup.

So do check, you may have something similar.

Related Topic