您好,欢迎访问一九零五行业门户网

介绍PHP7+Swoole/Nginx/Golang性能对比

推荐(免费):php7
qps对比
使用apache bench工具对nginx静态页、golang http程序、php7+swoole http程序进行压力测试。在同一台机器上,进行并发100共100万次http请求的基准测试中,qps对比如下:
软件qps软件版本
nginx 164489.92 nginx/1.4.6 (ubuntu)
golang 166838.68 go version go1.5.2 linux/amd64
php7+swoole 287104.12 swoole-1.7.22-alpha
nginx-1.9.9 245058.70 nginx/1.9.9
注:nginx-1.9.9的测试中,已关闭access_log,启用open_file_cache缓存静态文件到内存
更详细的测试细节历史测试数据:nginx/golang/swoole/node.js的性能对比测试环境
cpu:intel® core™ i5-4590 cpu @ 3.30ghz × 4内存:16g磁盘:128g ssd操作系统:ubuntu14.04 (linux 3.16.0-55-generic)压测工具
ab -c 100 -n 1000000 -k http://127.0.0.1:8080/
vhost配置
server {    listen 80 default_server;    root /data/webroot;    index index.html;}
测试页面
4a249f0d628e2318394fd9b75b4636b1hello world!473f0a7621bec819994bb5020d29372a
进程数量
nginx开启了4个worker进程
htf@htf-all-series:~/soft/php-7.0.0$ ps aux|grep nginxroot      1221  0.0  0.0  86300  3304 ?        ss   12月07   0:00 nginx: master process /usr/sbin/nginxwww-data  1222  0.0  0.0  87316  5440 ?        s    12月07   0:44 nginx: worker processwww-data  1223  0.0  0.0  87184  5388 ?        s    12月07   0:36 nginx: worker processwww-data  1224  0.0  0.0  87000  5520 ?        s    12月07   0:40 nginx: worker processwww-data  1225  0.0  0.0  87524  5516 ?        s    12月07   0:45 nginx: worker process
golang
测试代码
package mainimport (    log    net/http    runtime)func main() {    runtime.gomaxprocs(runtime.numcpu() - 1)    http.handlefunc(/, func(w http.responsewriter, r *http.request) {        w.header().add(last-modified, thu, 18 jun 2015 10:24:27 gmt)        w.header().add(accept-ranges, bytes)        w.header().add(e-tag, 55829c5b-17)        w.header().add(server, golang-http-server)        w.write([]byte(4a249f0d628e2318394fd9b75b4636b1\nhello world!\n473f0a7621bec819994bb5020d29372a\n))    })    log.printf(go http server listen on :8080)    log.fatal(http.listenandserve(:8080, nil))}
php7+swoole
php7已启用opcache加速器。
php版本
htf@htf-all-series:~/soft/php-7.0.0$ php -vphp 7.0.0 (cli) (built: dec 10 2015 14:36:26) ( nts )copyright (c) 1997-2015 the php groupzend engine v3.0.0, copyright (c) 1998-2015 zend technologies    with zend opcache v7.0.6-dev, copyright (c) 1999-2015, by zend technologies
测试代码
$http = new swoole_http_server("127.0.0.1", 9501, swoole_base);$http->set([ 'worker_num' => 4,]);$http->on('request', function ($request, swoole_http_response $response) { $response->header('last-modified', 'thu, 18 jun 2015 10:24:27 gmt'); $response->header('e-tag', '55829c5b-17'); $response->header('accept-ranges', 'bytes'); $response->end("<h1>\nhello swoole.\n</h1>");});$http->start();
相关免费学习推荐:php编程(视频)
以上就是介绍php7+swoole/nginx/golang性能对比的详细内容。
其它类似信息

推荐信息