缙哥哥的博客
与你分享我的点点滴滴生活

缙哥哥的博客升级到PHP7.2,附PHP7.1与7.2对比

280G全国流量的电信星海卡仅需29元/月,长期可续该套餐,随时可注销

缙哥哥在去年就已经使用PHP7版本了,那时就说PHP7比老版本快了很多很多,在今年,又分别出了7.1和7.2版本,从 WordPress 4.9.3 开始,该版本修复了 4.9 以来的34个问题。包括外观定制器更改、小工具、可视编辑器和php 7.2兼容性的修复。在缙哥哥做了一些对比后,最终决定将博客环境升级到PHP7.2版本。

PHP7.1/7.2对比图表呈现

汇总 bench.php bench.php + opcache micro_bench.php micro_bench.php + opcache
PHP7.1 1.3859 0.8133 5.6365 4.3600
PHP7.2 1.4514 0.7867 5.5840 3.7234

wordpress 压测

未开启 opcache

# php7.1
Concurrency Level:      10
Time taken for tests:   8.696 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      5215300 bytes
HTML transferred:       5189300 bytes
Requests per second:    11.50 [#/sec] (mean)
Time per request:       869.637 [ms] (mean)
Time per request:       86.964 [ms] (mean, across all concurrent requests)
Transfer rate:          585.65 [Kbytes/sec] received
# php7.2
Concurrency Level:      10
Time taken for tests:   8.528 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      5215500 bytes
HTML transferred:       5189300 bytes
Requests per second:    11.73 [#/sec] (mean)
Time per request:       852.793 [ms] (mean)
Time per request:       85.279 [ms] (mean, across all concurrent requests)
Transfer rate:          597.24 [Kbytes/sec] received

可以看到在未开启opcache的情况下,性能非常糟糕,10个并发的情况下,每个请求的响应时间已经非常长了,没有必要继续增加并发数了。

开启 opcache 之后

汇总 7.1 Requests per second (每秒) 7.1 Time per request (ms) 7.2 Requests per second (每秒) 7.2 Time per request (ms)
c10 n100 60.63 164.939 70.05 142.762
c20 n200 66.27 301.803 70.74 282.719
c30 n300 66.50 451.121 70.89 423.2
c40 n400 67.95 588.683 70.6 566.608

在开启opcache 之后,相对之前未开启的情况性能简直天壤之别。相比之下php7.2在wordpress压测上,QPS 稳定在70+ 相对php7.1 增加不少。

测试结果和配置参数以及服务器配置有关,仅供对比php7.1与7.2的性能。

赞(6) 打赏
转载请注明来源及链接:缙哥哥 » 缙哥哥的博客升级到PHP7.2,附PHP7.1与7.2对比
如需 WordPress 优化加速、二次开发、托管等服务,可联系我购买付费服务:点此联系我 | 近期站内热门福利:

评论 1

评论前必须登录!

 

  1. #1

    能否再分享下博客的主题?适应php7.x的,感谢!

    txsea5年前 (2019-01-31)

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册