PHP7-dev 与 PHP5.6 性能对比

昨天,在一台服务器上安装了PHP7-dev,安装方法点击这里查看

今天在同一台服务器上,使用相同的参数安装了PHP5.6.9,php.ini以及php-fpm.conf的配置也完全一致。

用来测试一下PHP7与PHP5相比,到底带来了多少性能上的提升。

本次测试使用Apache的ab工具,对全新安装的WordPress 4.2.2首页来进行测试。测试环境为 Ubuntu 14.04 64bit、Nginx 1.9.0、MySQL 5.5,除了PHP版本有所区别外,其它环境完全一致。

测试命令:

ab -n10000 -c200 "http://192.168.56.100/wordpress42/index.php"

PHP 5.6.9 测试结果:

This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.56.100 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.9.0
Server Hostname:        192.168.56.100
Server Port:            80

Document Path:          /wordpress42/index.php
Document Length:        0 bytes

Concurrency Level:      200
Time taken for tests:   345.350 seconds
Complete requests:      10000
Failed requests:        311
   (Connect: 0, Receive: 0, Length: 311, Exceptions: 0)
Non-2xx responses:      10000
Total transferred:      2935145 bytes
HTML transferred:       167007 bytes
Requests per second:    28.96 [#/sec] (mean)
Time per request:       6906.992 [ms] (mean)
Time per request:       34.535 [ms] (mean, across all concurrent requests)
Transfer rate:          8.30 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   4.0      1      70
Processing:   117 6675 10922.9   4561   91115
Waiting:      117 6675 10922.9   4561   91115
Total:        151 6676 10923.4   4562   91116

Percentage of the requests served within a certain time (ms)
  50%   4562
  66%   4627
  75%   4677
  80%   4715
  90%   4853
  95%   7544
  98%  60043
  99%  67049
 100%  91116 (longest request)

 

PHP7 测试结果:

This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.56.100 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.9.0
Server Hostname:        192.168.56.100
Server Port:            80

Document Path:          /wordpress42/index.php
Document Length:        0 bytes

Concurrency Level:      200
Time taken for tests:   169.558 seconds
Complete requests:      10000
Failed requests:        124
   (Connect: 0, Receive: 0, Length: 124, Exceptions: 0)
Non-2xx responses:      10000
Total transferred:      2893349 bytes
HTML transferred:       66588 bytes
Requests per second:    58.98 [#/sec] (mean)
Time per request:       3391.161 [ms] (mean)
Time per request:       16.956 [ms] (mean, across all concurrent requests)
Transfer rate:          16.66 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   4.1      1      70
Processing:    57 2911 6714.7   1946   67058
Waiting:       57 2911 6714.6   1946   67058
Total:         93 2912 6715.7   1947   67059

Percentage of the requests served within a certain time (ms)
  50%   1947
  66%   1971
  75%   1988
  80%   2001
  90%   2056
  95%   2215
  98%  16049
  99%  60003
 100%  67059 (longest request)

我们可以比较一下测试结果的关键值,如下:

                               PHP5               PHP7
Failed requests:               311                124
Requests per second:           28.96              58.98
Time per request:              34.535             16.956

好了,一起看下结果吧。

Failed requests(失败的请求数量),PHP5为311,PHP7为124,失败数量降低了一半以上

Requests per second(吞吐率),PHP5近似为29次/秒,PHP7近似为59次/秒,吞吐率提升了一倍左右

Time per request(服务器平均请求等待时间),PHP5近似为35ms,PHP7近似为17ms,服务器请求等待时间缩短了一半

 

目前PHP7还只是处于开发版本阶段,希望10月份发布的正式版本PHP7在性能上还会有更大的提升!

欢呼吧PHPer,春天就要来了~~

P.S. 有时间了再做个PHP7与HHVM的性能对比,看看会得出什么结果。

Categories: PHP

发表评论

电子邮件地址不会被公开。 必填项已用*标注