Wednesday, December 3, 2014

php - httpd memory usage (Apache/2.4.16 (Amazon))

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?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...