Apache httpd processes and PHP out of memory
Posted
by
Ofri
on Server Fault
See other posts from Server Fault
or by Ofri
Published on 2012-10-24T16:52:12Z
Indexed on
2012/10/24
17:03 UTC
Read the original article
Hit count: 287
I have a VPS running apache-php-mysql on centos and a single drupal website installed. The VPS has 256MB of RAM (could be the root cause of all my problems... maybe I just need more). Whenever I try to open my website from multiple browser tabs (about 8... not 800) all at once, apache crashes! I have this on the log:
[Wed Oct 24 11:26:31 2012] [error] [client xxx] PHP Fatal error: Out of memory (allocated 28049408) (tried to allocate 201335 bytes) in xxx on line 2139, referer: xxx
I have read many many posts here, but I think there is something fundamental that I'm missing - If I understand correctly some php script tried to allocate 200K after allocating 28MB, and fails to do so.
First question is: should this cause the apache to crash???
Next, I tried to look at 'top' command while I do my little test. Indeed I see 7 httpd processes, each reserving about 30MB - which explains why my RAM runs out.
How do I prevent apache from creating new processes until it's out of memory?
I tried configuring /etc/httpd/conf/httpd.conf like this:
<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 1
ServerLimit 1
MaxClients 1
MaxRequestsPerChild 100
</IfModule>
But got the same exact result!
What am I missing?
Thanks a lot!
© Server Fault or respective owner