[prog] Freeing memory in PHP/Apache
Rasjid Wilcox
rasjidw at openminddev.net
Sun May 2 22:11:39 EST 2004
On Sunday 02 May 2004 19:55, Almut Behrens wrote:
> On Sat, May 01, 2004 at 11:20:14AM +1000, Rasjid Wilcox wrote:
> > I am using a PHP based CMS (MySource by Squiz.net) and although quite
> > good it is a little heavy handed with the memory usage.
Actually, I tried out WebGUI (a mod_perl based CMS) last night, and it makes
MySource look resource gentle.
> > Upon starting apache, each child uses about 3MB of memory. However after
> > serving up a page through MySource, the memory usage of the child
> > concerned jumps to about 12MB and stays there. (Actually, I get two such
> > instances.) Since this is a User-Mode-Linux based virtual server, I only
> > have 96MB ram, and so this was quite a problem.
<snip lots of useful info>
> More practical techniques involve setting MaxRequestsPerChild to some
> small value (as you did -- '1' seems a bit extreme, though...), or
> killing apache child processes automatically when their memory usage
> becomes excessive (i.e. memory-usage-based, instead of request-count-
> based), or simply having less apache children run in parallel
> (-> StartServers, MinSpareServers, MaxSpareServers, MaxClients).
> According to some benchmarks I did myself, the latter often results in
> a better overall performance when the system is short of memory.
Thank you Almut for your information. I am now testing:
MinSpareServers = MaxSpareServers = 1
and I'll see how that goes. So far it is okay in that I'm not using swap
(well, apache does not seem to be anyway - there seems to be about 48MB of
stuff just permanently swapped out), but it is very close to the line even
when the server is being completely idle. With MaxRequestsPerChild = 1, when
the system was idle it at least had some spare memory floating around. (Yes,
I am including 'buffers' as spare memory.) But I agree that constantly
spawning and killing children is not really ideal either.
Hopefully I'll be able afford to upgrade the virtual machine to 128MB of
memory sometime soon, and it will be less of an issue.
Thanks again,
Rasjid.
--
Rasjid Wilcox
Canberra, Australia (UTC +10 hrs)
http://www.openminddev.net
More information about the Programming
mailing list