>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

Reply via email to