Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawbacks or side-effects when compiling PHP with --enable-maintainer-zts (to use php pthread)

I have a web application and is running fine with PHP 5.5.5 on a production environment.

On the same server now I need to run some PHP scripts that make use of php pthread (v. 2.0.10)

Is it safe to rebuild php with --enable-maintainer-zts (to allow use of pthreads) and use the same executable both for the web application and the CLI scripts that use php-pthread ?

Or should I make two builds of PHP: php, php-zts and use the former for the web app and the latter for the CLI scripts ?

As --enable-maintainer-zts is not enabled by default I assume it have some drawbacks or worse (as I have read here https://github.com/travis-ci/travis-ci/issues/985) may introduce misbehaviours (bugs).

The web stack is nginx + php-fpm + mySql on Mac OS X 10.9.5.

I want it to be clear: phtread will not be used by the web application scripts. Only by the CLI scripts.

like image 201
Paolo Avatar asked Mar 24 '26 22:03

Paolo


1 Answers

From http://www.phpinternalsbook.com/build_system/building_php.html

(emphasis mine)

--enable-debug enables debug mode

[...]

--enable-maintainer-zts enables thread-safety.

[...]

you should not use either of these options if you want to perform performance benchmarks for your code, as both can cause significant and asymmetrical slowdowns.

--enable-maintainer-zts seem not harmful but affects performances. So it's definitely not advisable in a production environment.

A separate build of PHP with --enable-maintainer-zts in order to use php pthread in CLI scripts is the appropriate way to go.

like image 143
Paolo Avatar answered Mar 27 '26 13:03

Paolo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!