Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51030 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10180 invoked from network); 14 Dec 2010 19:22:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Dec 2010 19:22:45 -0000 X-Host-Fingerprint: 95.31.13.88 xdmitri2.static.corbina.ru Received: from [95.31.13.88] ([95.31.13.88:26304] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/89-59442-304C70D4 for ; Tue, 14 Dec 2010 14:22:43 -0500 Message-ID: To: internals@lists.php.net References: Date: Tue, 14 Dec 2010 22:22:41 +0300 Lines: 68 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 X-RFC2646: Format=Flowed; Original X-Posted-By: 95.31.13.88 Subject: Re: PHP Performance in Apache: Multi-Process vs Multi-Threaded From: dmda@yandex.ru ("jvlad") "Israel Ekpo" wrote in message news:AANLkTi=ixWQkKovKYuLuQckDvkLQY2nYEyG6PJfZAn-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 are 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 there 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 include > 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 case you may want to get what so ever php and apache distributed 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