Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51031 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94428 invoked from network); 15 Dec 2010 10:21:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Dec 2010 10:21:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=doctorrock83@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=doctorrock83@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: doctorrock83@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:35426] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B7/93-58921-E96980D4 for ; Wed, 15 Dec 2010 05:21:19 -0500 Received: by qwj8 with SMTP id 8so1769331qwj.29 for ; Wed, 15 Dec 2010 02:21:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:sender:received :in-reply-to:references:from:date:x-google-sender-auth:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=FAtMf68dnZUdaPdNOc70801npYXsmtuDeRifedUnXbY=; b=vZPjbUpdR2rHmPqDHdwNDUbJSAFzdvNSSGQkwtqiG1JTNVB6C+hS031FmRVU96ol4B f9QWHVYOea+mLPqkym90zHad4QmY6LUDKF9D3+gsr+1bS9Uqxf+V3NtqYUsfpUy/Zk/z Qhl/Aqk8LEMLgd0W91gYG1xoHDEUWovxuPUu8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; b=KoEYmScU3hJ9vVI5T8N+adH9JRAHTOe3cURPMtU+KPA/fEFamuoB0R2L3d9+Vncne4 gjGw3PUayuHBVVr35Ff10qWKsloaDX5Y4oJWby18LCIcvcHZwsIsEjPjS0WSCuLC7vwY Hmmi+io9wx1MhEAl0cHDItv3/69+bydW0MbZQ= Received: by 10.229.230.10 with SMTP id jk10mr417840qcb.245.1292408475812; Wed, 15 Dec 2010 02:21:15 -0800 (PST) MIME-Version: 1.0 Sender: doctorrock83@gmail.com Received: by 10.220.59.5 with HTTP; Wed, 15 Dec 2010 02:20:35 -0800 (PST) In-Reply-To: References: Date: Wed, 15 Dec 2010 11:20:35 +0100 X-Google-Sender-Auth: msCvMDVZfz1FZiagk4jsUi-H09A Message-ID: To: jvlad Cc: internals@lists.php.net Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: PHP Performance in Apache: Multi-Process vs Multi-Threaded From: jpauli@php.net (Julien Pauli) Well, I would say that if your problem is memory, you should consider threads as they all share the same memory space in their process. Apache's children can weight very heavy if PHP's been compiled to support lots of extensions, you can happen with ~40/50Mb per process which is very huge. Considerating 50 parallel processes eat up 2-3Gb for example. In threaded environment, the best thing you'll get is a lot of memory savings. The impact on CPU time is roughtly the same that with processes (Unix). Beware of non thread safe extensions/libs ; they'll cause you brain damage for sure. J.Pauli On Tue, Dec 14, 2010 at 8:22 PM, jvlad wrote: > "Israel Ekpo" wrote in message > news:AANLkTi=3DixWQkKovKYuLuQckDvkLQY2nYEyG6PJfZAn-G@mail.gmail.com... >> In multi-process environments, such as FastCGI, Apache Prefork MPM etc, >> PHP >> needs to execute the MINIT and MSHUTDOWN functions for all loaded >> extensions >> on every request. > > You're not correct here. A process can handle quite a lot of requests and > MINIT/MSHUTDOWN is executed only once. > So the MINIT/MSHUTDOWN overhead is negletable. > >> It is also more expensive to create new processes than to create new >> threads. > > Correct, but it's rarely needed to create them in both cases. So expense = of > creation plays almost no role. > What plays role is switching the context when some overlapping requests a= re > processed. With thread it's less expensive. > But still, switching is a huge overhead when you run a server with 1K or = 10K > overlapping requests. > If you talk about 10 or 40 - there is almost no difference. > >> In one-on-one comparisons between scripts executed only once in ZTS mode >> and >> scripts executed once in non-ZTS mode, >> I noticed that the one in non-ZTS mode was slightly faster > > that's because in ZTS case all data is in thread-safe structures and ther= e > is quite a big overhead accessing any field of the structures. > >> and this seems to >> be the main reason why most people go with the non-ZTS enabled setups. > > No. Php if we talk about php with all its extensions is not threadsafe at > all. Many of the extensions allocate static data and inherently > non-thread-safe. > >> But the reason for this slight difference in speed is because of the >> differences in the data structure for globals for ZTS and non-ZTS modes. > > correct. > >> Other reasons people have cited for going with non-threaded setups inclu= de >> stability which I guess we should not really be concerned about if >> non-threadsafe extensions are excluded. > > Correct. But you never know which one is truly threadsafe. > I'd only say that it's safer to use extensions that do not depend on 3rd > party libraries at all, or at least > depend on libraries written with threadsafety in mind. > >> Has anyone performed any load tests benchmarks comparing the two setups >> (Multi-Process vs Multi-Threaded)? > > Could you please shed some light on what load volume you're talking about= ? > 1, 10, 100, 1K, or10K of requests per second? > > with a regular web site which is handling ~4-5K visitors a day, you can > hardly get more than 10-15 requests per second. > In this =9Acase you may want to get what so ever php and apache distribut= ed > with your OS and do not spend you time on anything else. > If you foresee 10K requests per second, it's better not to use PHP and > especially not to use Apache at all. > > -j > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >