2

I'm running an apache server (default configuration, mod_php) on an amazon linux VM with just 1G of RAM.

There are two kinds of php applications running: memory heavy ones that are executed not so often (httpd processes get 50mb in size each) and memory light ones that are executed often.

When I restart apache and look at the size of the httpd processes it looks like this:

sudo service httpd restart
ps aux | grep 'httpd' | awk '{print $6/1024 " MB";}'
24.7266 MB
14.9805 MB
14.9805 MB
14.9805 MB
14.9805 MB
14.9805 MB
2.00391 MB

When I https:// just ones to one of the memory heavy php apps (a drupal 7 installation) the same command output this:

24.7266 MB
14.9805 MB
47.0195 MB
18.6133 MB
18.5781 MB
18.582 MB
14.9805 MB
14.9805 MB
14.9805 MB
14.9805 MB
14.9805 MB
14.9805 MB
14.9805 MB
2.05078 MB

The problem is that even when the server becomes idle it keeps some of these large 50MB processes created to serve the memory heavy drupal requests. Eventually when I get too many of these it uses almost all the server memory so I cannot use the server for anything else. I could set a stricter limit on the amount of processes httpd can create so there would be less 50MB processes but that would punish the light applications as there are now less processes to handle their requests:

  • How can I make apache free memory memory more often?
  • Or is there a better tool out there than apache?
glennv
  • 121
  • 1
  • nginx + php-fpm is much lighter option in terms of resources if you want to give it a shot. if you don't want to poke with nginx you can try apache + php-fpm because then php will be handled separately (not within apache process) so you can spare some mem this way as well. tuning apache if using defaults is also good thing check here http://serverfault.com/questions/644622/tuning-apache2-prefork-maxclients-serverlimit/644632#644632 – Hrvoje Špoljar Jan 25 '16 at 12:52

1 Answers1

1

Parts of my answer here may be relevant. We run Apache in a memory-constrained environment and Apache processes used to gradually use up all the available memory.

We cured it by reducing the MaxConnectionsPerChild directive to 2500. At our traffic levels this meant child processes were recycled about twice an hour, freeing up the memory they were using.

Perhaps you could try that.

hillsy
  • 231
  • 2
  • 4