High RAM usage by Apache without any visitors

6,052

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.

Share:
6,052

Related videos on Youtube

Gijo Varghese
Author by

Gijo Varghese

Updated on September 18, 2022

Comments

  • Gijo Varghese
    Gijo Varghese over 1 year

    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

    • user9517
      user9517 about 8 years
      Your server is too small for your workload.
    • Gijo Varghese
      Gijo Varghese about 8 years
      but no visitors. Just php files and mysql. How can they consume this much of memory even without running
    • Gijo Varghese
      Gijo Varghese about 8 years
      When i listed apache modules, I got a long list. I'm confused on which one to disable and which one to enable.
    • Siddharth sharma
      Siddharth sharma about 8 years
      For this you have to read Apache Doc, we actually don't know how you are using your apache server. All module description are available in docs. Only select what you need and disable rest. This will surely improve your performance. I suggest you to remove all the proxy,optional,dav and CGI modules. You can find all the Loaded modules in /etc/httpd/conf.modules.d/ directory.
    • Aaron Hudon
      Aaron Hudon about 6 years
      It also depends on the mpm process model and the settings. If you want to minimize usage and recover in idle state go for small prestart/minimum servers, use threading and exit after small number of requests and a low number of spare threads. Use the mod_status page to see your (idle) workers.