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 <d...@yandex.ru> wrote:
> "Israel Ekpo" <israele...@gmail.com> wrote in message
> news:aanlkti=ixwqkkovkyuluqckdvklqy2nyeyg6pjfza...@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
>
>
>
> --
> 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