Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

to use thread safe or non thread safe php?

Tags:

php

apache

i wonder which installation to use for my php? i will be using apache. i read that thread safe is faster with apache and non thread safe for IIS? isit true (good to know if i intend to use iis later)?

like image 272
Jiew Meng Avatar asked Aug 17 '10 08:08

Jiew Meng


1 Answers

If you use mod_php and MPM that creates threads to handle requests (instead of processes), you should go with thread-safe, as otherwise you might get a bunch of undesired side effects when multiple PHP scripts are running simultaneously in different threads in same process space. Apache2 uses the mpm_winnt MPM by default on Windows, which creates threads to handle incoming requests. So if you use that, go with the thread safe binary. Please note though, that even if PHP itself is thread-safe, the libraries/extensions you use might not be. So you might still have problems with mod_php and a threaded MPM, even with thread safe PHP binaries. For more information, check this FAQ entry: http://fi.php.net/manual/en/faq.installation.php#faq.installation.apache2

However if you're not using mod_php (eg. you're using FCGI), or you're using mod_php but are using a MPM that spawns processes instead of threads to handle request (eg. the prefork MPM), then you should use the non-thread safe binary, as it's more efficient than the thread safe version, and since PHP scripts run in their own process space when you've got your webserver setup this way, there's no reason for the extra overhead of thread safe binaries.

like image 174
reko_t Avatar answered Sep 20 '22 11:09

reko_t