From owner-freebsd-questions@FreeBSD.ORG  Sun Apr 25 08:49:12 2010
Return-Path: <owner-freebsd-questions@FreeBSD.ORG>
Delivered-To: freebsd-questions@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B4831106566B
	for <freebsd-questions@freebsd.org>;
	Sun, 25 Apr 2010 08:49:12 +0000 (UTC)
	(envelope-from m.seaman@infracaninophile.co.uk)
Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk
	[IPv6:2001:8b0:151:1::1])
	by mx1.freebsd.org (Postfix) with ESMTP id F2DD38FC1B
	for <freebsd-questions@freebsd.org>;
	Sun, 25 Apr 2010 08:49:11 +0000 (UTC)
Received: from seedling.black-earth.co.uk (seedling.black-earth.co.uk
	[81.187.76.163]) (authenticated bits=0)
	by smtp.infracaninophile.co.uk (8.14.4/8.14.4) with ESMTP id
	o3P8n7D7024637
	(version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO)
	for <freebsd-questions@freebsd.org>;
	Sun, 25 Apr 2010 09:49:08 +0100 (BST)
	(envelope-from m.seaman@infracaninophile.co.uk)
Message-ID: <4BD40203.90203@infracaninophile.co.uk>
Date: Sun, 25 Apr 2010 09:49:07 +0100
From: Matthew Seaman <m.seaman@infracaninophile.co.uk>
Organization: Infracaninophile
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US;
	rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4
MIME-Version: 1.0
To: freebsd-questions@freebsd.org
References: <4BD394BC.7030501@netmusician.org>
In-Reply-To: <4BD394BC.7030501@netmusician.org>
X-Enigmail-Version: 1.0.1
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: clamav-milter 0.96 at happy-idiot-talk.infracaninophile.co.uk
X-Virus-Status: Clean
X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_ADSP_ALL,
	SPF_FAIL autolearn=no version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	happy-idiot-talk.infracaninophile.co.uk
Subject: Re: Advice for finding a leaky Apache (probably PHP) process
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
	<mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions>
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
	<mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 25 Apr 2010 08:49:12 -0000

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 25/04/2010 02:02:52, Joe Auty wrote:

> I'm wondering if you guys have any general tips on how to find the
> Apache process/app that is gobbling up my RAM randomly until my machine
> crashes and I'm forced to reboot? I'm tired of staring at top and
> working with flimsy hacks such as 10 minute Apache restart cronjobs.
> 
> This seems to start (or worsen) after updating to PHP 5.3, but this is
> not happening on my test machine where PHP 5.3 is also installed and the
> same apps are used (although not publicly).
> 
> General tips and suggestions are welcome here!

You need to divide and conquer.  Basically, you've got all of your PHP
applications running in one PHP interpreter instance per apache child
and you won't be able to tell which is the problem app until you can
separate them out.

One way of doing that is the simple and obvious method of commenting out
each application in turn from the apache config, leaving it running for
a while and seeing what happens to memory usage.  This is OK only if
you're happy to turn off chunks of site functionality while testing.

Alternatively, you can set up several different instances of apache,
each configured to run one of the php applications and each binding to a
different port on the loopback interface.  Then use another apache with
a bit of mod_proxy or mod_rewrite glue to redirect the queries
internally.  Or you could replace the front facing apache instance with
something like varnish.

Finally, it has been suggested else-thread that you contemplate
switching to an alternative HTTP daemon like nginx -- in that case,
you'ld want to be running your PHP apps under fCGI rather than embedded
in the HTTP daemon.  Running each different PHP app in a separate fCGI
process shouldn't be too hard to set up.  While this is a valid
alternative configuration for your site, the Scientist in me complains
that as an attempt to find out why your PHP apps are misbehaving, there
are too many uncontrolled changes for it to be a good diagnostic.

	Cheers,

	Matthew

- -- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                  Kent, CT11 9PW
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvUAgMACgkQ8Mjk52CukIyCJwCfW+UWZkYxNtTCtEg1NhCkRmTR
Mg8AoIYO4qRSswo/3gMWhVqrQAkzv7PX
=vFG3
-----END PGP SIGNATURE-----