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!
My PHP memory_limit is 128M (confirmed by the drupal admin pages...) The output of free -m:
total used free shared buffers cached Mem: 256 226 29 0 0 0 -/+ buffers/cache: 226 29 Swap: 0 0 0
What can I do to make apache consume less memory? Can't I save memory on the expense of slower responses?