Apache2 with worker MPM on 5.3

Matthew Seaman m.seaman at infracaninophile.co.uk
Tue Feb 15 03:10:13 PST 2005


On Thu, Feb 10, 2005 at 01:20:10PM +0200, Toomas Aas wrote:

> We are running a fairly busy website with Apache 2.0.52. At times
> a lot of httpd processes gather up and consume all the available
> memory, which slows down web access.

You should check and see if apache is validly spawning all those
sub-processes to cope with a traffic spike, or whether there's some
condition that's gumming up the works -- having a whole row of apace
processes hanging because they are attempting to talk to some database
that itself has gone a bit tits-up and isn't responding correctly
could quite easily lead to the sort of effect you're seeing.

An important tip with running Apache on high performance we sites is
to limit the maximum number of clients that will be spawned at any one
time so that it doesn't drive the system into swapping -- essentially
decide how muchof the system RAM you can dedicate to Apache, look at
the size of an individual apache process via ps(1), divide one by the
other and use that as the 'MaxClients' setting in httpd.conf.

Note that loading such modules as mod_perl or mod_php will increase
the size of individual apace processes enormously.  Don't load such
modules unless you actually need them, and in some cases it may even
be worth running several instances of apache, both with and without
those modules, plus adroit use of proxying and mod_rewrite in order to
get the best performance.

Note too that Apache 1.3.x processes are generally smaller than
equivalently configured Apache 2.0.x processes so may help you get the
most out of your server.

> Apache2 was installed from ports and defaulted to prefork MPM. I read
> from the Apache performance tuning document that worker MPM may perform
> better on busy websites and has smaller memory footprint. Is it safe to
> run Apache2 with worker MPM on FreeBSD 5.3? There must be a reason why
> prefork is the default...

Prefork is the original mechanism Apache used to multiplex itself.  It
generally works exceedingly well on Unix systems where fork(2) is fast
and efficient, which is why it is the default.  Threaded MPMs may or
may not be better for your particular situation, depending on:

    i) OS -- some have vastly better implemented threading
    infrastructure than others.  For some, the overhead of
    fork()+exec() is huge, making use of threads anecessity.

    ii) Web application -- if you're just serving static HTML, then
    there's no need to use anything other than the prefork MPM.  On
    the other hand, if you're running large, complicated web apps
    written in perl, PHP, Java etc. then a threaded MPM may fit better
    with the design of that particular application.

    iii) The nature of the workload -- how much data are you shifting,
    how much does it cost your servers to generate that data, how does
    demand vary with time-of-day or day-of-week.

There isn't any one-size-fits-all answer.  You will have to experiment
with your particular set up in order to tune it for maximum
performance.

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       8 Dane Court Manor
                                                      School Rd
PGP: http://www.infracaninophile.co.uk/pgpkey         Tilmanstone
Tel: +44 1304 617253                                  Kent, CT14 0JL UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 305 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20050214/4f591365/attachment.bin


More information about the freebsd-questions mailing list