swoole nginx对比

[root@~]# php -v
PHP 7.1.7 (cli) (built: Mar  9 2018 13:33:38) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
php版本

[root@ ~]# php --ri swoole
swoole
swoole support => enabled

Version => 2.0.10


[root@~]# nginx -v
nginx version: nginx/1.12.2

同样以输出helloworld为准
原生php
Requests per second:    6853.90 [#/sec] (mean)
Time per request:       14.590 [ms] (mean)
Time per request:       0.146 [ms] (mean, across all concurrent requests)
Transfer rate:          1265.03 [Kbytes/sec] received

swoole
代码如下
$http = new swoole_http_server("0.0.0.0", 9502);
$http->on('request', function ($request, $response) {
    $response->end('helloworld');
});
$http->start();


测试结果如下、

Total transferred:      79000000 bytes
HTML transferred:       5000000 bytes
Requests per second:    18973.77 [#/sec] (mean)
Time per request:       5.270 [ms] (mean)
Time per request:       0.053 [ms] (mean, across all concurrent requests)
Transfer rate:          2927.59 [Kbytes/sec] received

相比之下 swoole 的 qps 是nginx 的将近三倍的样子。
另外使用基于swoole封装的easyswoole框架输出是nginx的1.2倍左右。
swoole 的性能还是很强悍的

你可能感兴趣的:(php)