php - 使用 --enable-maintainer-zts 编译 PHP 时的缺点或副作用(使用 php pthread)

标签 php php-pthread

我有一个网络应用程序,在生产环境中使用 PHP 5.5.5 运行良好。

现在我需要在同一台服务器上运行一些使用 php pthread (v. 2.0.10) 的 PHP 脚本

使用 --enable-maintainer-zts 重建 php 是否安全(以允许使用 pthreads)并使用相同的可执行文件两者 对于使用 php-pthread ?

的 Web 应用程序和 CLI 脚本

或者我应该构建两个 PHP:phpphp-zts 并将前者用于 Web 应用程序,将后者用于 CLI 脚本?

由于默认情况下未启用 --enable-maintainer-zts 我认为它有一些缺点或更糟(正如我在这里阅读的 https://github.com/travis-ci/travis-ci/issues/985 )可能会引入不当行为(错误)。

在 Mac OS X 10.9.5 上,Web 堆栈是 nginx + php-fpm + mySql

我想明确一点:phtread不会 由网络应用程序脚本使用。仅通过 CLI 脚本。

最佳答案

来自 http://www.phpinternalsbook.com/build_system/building_php.html

(强调我的)

--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 似乎无害但会影响性能。所以在生产环境中绝对不可取。

为了在 CLI 脚本中使用 php pthread,使用 --enable-maintainer-zts 单独构建 PHP 是合适的方法。

关于php - 使用 --enable-maintainer-zts 编译 PHP 时的缺点或副作用(使用 php pthread),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35895018/

相关文章:

javascript - 用 php 内容刷新一个 div

php - 您的 SQL 语法有误;检查对应的手册等

php - 无法加载动态库 'C:\php\ext\php_pthreads.dll'

php - PHP Pthread 类中的 Yii 框架上下文

php - 从查询中获取 MySQL 结果集大小

php - 使用 select() 的简单 TCP 服务器,为什么 "longest request"这么高?

php - 如何使数组第一个值作为第二个值的键作为php数组中的值