Hi,
I have spent a lot of time last year measuring php performance on
multi-threaded vs single threaded fastcgi.
I had used iplanet web server (instead of apache) for my measurement.  Out of
the box single threaded php apps were very close (better) than multi-threaded
versions but when we started optimizing php for multi-threaded environment,
overall results were extremely positive (>35% faster than single threaded php
for an ecommerce apps).  There is a lot of scope of improving multi-threaded
php. Some of the areas we looked at are:
* memory management
* file operations (caching stats call etc.)
* Session data caching (memsession php plugin)
* Removing TSRMLS_FETCH for emalloc/efree
* Reduce malloc and replace with emalloc in various php code paths.
* Pre-compute hash values of string constants at init-time rather than
when processing a request.
* APC enhancement for multithreaded PHP apps.
* Using MPSS heap inside web server.


As far as multithreaded apps in production is concerned, entire java land runs
inside multithreaded servers and runs very nicely. php however has never been
optimized for multi-threaded web servers much so it runs lot nicer in single
threaded fastcgi environments.

Regards,
Basant.

On Tue, Dec 14, 2010 at 10:30 AM, Gerry Reno <gr...@verizon.net> wrote:
> From our experience if you wish to serve any kind of PHP apps with
> internationalization using the popular GNU gettext system ( and right
> now there are many of these) then you must use a non-threaded webserver
> engine since GNU gettext library is not yet thread-safe (because GNU
> gettext process environment variables can be set by any thread which
> will drive the underlying GNU gettext library and these would affect
> every thread in the process).
>
> If you do not care about internationalization or using the most popular
> system for translations, GNU gettext, then you can choose any webserver
> engine type, threaded or non-threaded that your application will support.
>
> Personally, I would never run a threaded engine in production.
> Cross-thread contamination problems are most difficult to track down.
> And I prefer to have complete isolation between connections which makes
> it much simpler to track down problems.  The so far tiny difference in
> performance is outweighed by the isolation and debugging efficiencies
> obtaining using a non-threaded webserver engine.
>
>
> -Gerry
>
>
>
> On 12/14/2010 01:06 PM, Israel Ekpo wrote:
>> Hi All,
>>
>> I have a few questions about the performance of PHP web applications *under
>> load* and I would appreciate if there is anyone that would like to share
>> their experiences in terms of any benchmarks or observations.
>>
>> *Background Information*
>>
>> 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.
>>
>> In a multi-threaded environment, such as Apache Worker MPM, with Zend Thread
>> Safety is enabled,
>> PHP only needs to execute MINIT and MSHUTDOWN functions once for each
>> extension and not each time a new thread is created to serve a request.
>>
>> It is also more expensive to create new processes than to create new
>> threads.
>>
>> 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 and this seems to
>> be the main reason why most people go with the non-ZTS enabled setups.
>> 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.
>>
>> 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.
>>
>> Since it is generally more expensive to create new processes than new
>> threads, I believe that under high load, php in ZTS mode (multi-threaded
>> environment) will perform better than an identical setup in NTS mode
>> (multi-process).
>>
>> *Problem*
>>
>> I noticed that Zend Server is using PHP in FastCGI mode (multi-process NTS)
>> and I am contemplating setting up apache in worker mode (threaded mode) and
>> compiling php in ZTS mode instead.
>>
>> Has anyone performed any load tests benchmarks comparing the two setups
>> (Multi-Process vs Multi-Threaded)?
>>
>> Are there PHP extensions that cause issues in threaded environments that I
>> should avoid?
>>
>> Are there any internals information or any other reasons why I should choose
>> ZTS over NTS or vice versa?
>>
>> Any useful feedback will be highly appreciated.
>>
>> Thanks.
>>
>>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to