From owner-freebsd-questions@FreeBSD.ORG Fri Dec 10 06:37:27 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 08D7F1065673 for ; Fri, 10 Dec 2010 06:37:27 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3fd3:cd67:fafa:3d78]) by mx1.freebsd.org (Postfix) with ESMTP id 618D68FC0C for ; Fri, 10 Dec 2010 06:37:26 +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 oBA6bKMM001291 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 10 Dec 2010 06:37:21 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.8.3 smtp.infracaninophile.co.uk oBA6bKMM001291 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infracaninophile.co.uk; s=201001-infracaninophile; t=1291963041; bh=ELt11M+NQHV1j6OVNJ2tKUeAhhijiuBli4iyYCxX+DM=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Cc:Content-Type:Date:From:In-Reply-To: Message-ID:Mime-Version:References:To; z=Message-ID:=20<4D01CA99.9020706@infracaninophile.co.uk>|Date:=20F ri,=2010=20Dec=202010=2006:37:13=20+0000|From:=20Matthew=20Seaman= 20|User-Agent:=20Mozilla/5.0=20(M acintosh=3B=20U=3B=20Intel=20Mac=20OS=20X=2010.6=3B=20en-US=3B=20r v:1.9.2.12)=20Gecko/20101027=20Thunderbird/3.1.6|MIME-Version:=201 .0|To:=20Laszlo=20Nagy=20|CC:=20questions@fr eebsd.org,=20danieleff@gmail.com|Subject:=20Re:=20What=20is=20load ing=20my=20server=20so=20much?|References:=20<4D00BDF8.6020206@sho pzeus.com>|In-Reply-To:=20<4D00BDF8.6020206@shopzeus.com>|X-Enigma il-Version:=201.1.1|OpenPGP:=20id=3D60AE908C|Content-Type:=20multi part/signed=3B=20micalg=3Dpgp-sha1=3B=0D=0A=20protocol=3D"applicat ion/pgp-signature"=3B=0D=0A=20boundary=3D"------------enig50929FA3 14BAB869CCC0AA72"; b=D6DJE8afYeojvcNuvDu8r77y+uZvJz2BDbz0PH0xbWr2BZezcGcAGweR6w3lZZREk 7feURoIQd/WnuBwOGiu+hcPeFL1LM9Ev+aGu6eOv4k0Hsa2NZjzxRqwUdTVZpnYUP1 oFuaFnPDk1UIVr1l/d14+BtXZjCIu3cpvNaASpyA= Message-ID: <4D01CA99.9020706@infracaninophile.co.uk> Date: Fri, 10 Dec 2010 06:37:13 +0000 From: Matthew Seaman User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 MIME-Version: 1.0 To: Laszlo Nagy References: <4D00BDF8.6020206@shopzeus.com> In-Reply-To: <4D00BDF8.6020206@shopzeus.com> X-Enigmail-Version: 1.1.1 OpenPGP: id=60AE908C Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig50929FA314BAB869CCC0AA72" X-Virus-Scanned: clamav-milter 0.96.5 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_FAIL autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on lucid-nonsense.infracaninophile.co.uk Cc: questions@freebsd.org, danieleff@gmail.com Subject: Re: What is loading my server so much? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Dec 2010 06:37:27 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig50929FA314BAB869CCC0AA72 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: quoted-printable On 09/12/2010 11:31, Laszlo Nagy wrote: > Today something happened. Number of http processes went up to 200. As a= > result, number of connections to database also went up to 200, and the > web server is now refusing clients with "Cannot connect to database" > messages (coming from PHP). This is a classic scenario. Some burst of traffic causes your apache to spawn more child processes than will all fit in RAM at one time. Consequently, the system starts to swap. Swapping kills performance. This slows everything down so much that there are always requests waiting for apache to process, so apache will never find any idle children to kill off. Result misery. The answer is to limit the number of child processes apache will spawn. Decide how much of your available RAM you can devote to Apache. Look at top(1) to find the maximum size apache processes grow to. The ratio of those two sizes is the maximum number of apache processes your system can support. Limiting the total number of apache processes sounds counter-intuitive. What happens when you get sufficient traffic that apache maxes out? Web queries will generally be queued up until there's an apache child free to handle them. Generally that will take from a few 10s of milliseconds on up -- although if you're regularly getting into a state where your webserver takes seconds to answer, then it's time to get more beefy hardware. Cheers, Mstthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate JID: matthew@infracaninophile.co.uk Kent, CT11 9PW --------------enig50929FA314BAB869CCC0AA72 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0ByqAACgkQ8Mjk52CukIx9awCfdRZAjdmSkbPXuX+zOkthi6kQ 7cQAnAsR/awYyqE9q6NuQfI/K57QaIG8 =XO3v -----END PGP SIGNATURE----- --------------enig50929FA314BAB869CCC0AA72--