最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Node.JS与PHP CLI Server对HTTP服务器性能测试
时间:2015-02-09 编辑:简简单单 来源:一聚教程网
环境:
64位Ubuntu14.04,i5-3230M
PHP5.4.31 with ZendOPcache
Node.JS 0.10.35
Node.JS 测试
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html;charset=UTF-8'});
res.write('
res.end();
}).listen(8082, '127.0.0.1');
运行程序:
node t.js
查看系统CPU空闲率:
sar 1
压力测试,并发100,完成10万请求:
ab -c100 -n100000 http://127.0.0.1:8082/t.js
内存从11MB涨到61MB,系统CPU空闲率65%, RPS达到6049.
PHP CLI Server 测试
php header('Content-Type: text/html;charset=UTF-8'); ?>
运行程序:
php -S 127.0.0.1:8081 -t ./
查看系统CPU空闲率:
sar 1
压力测试,并发100,完成10万请求:
ab -c100 -n100000 http://127.0.0.1:8081/t.php
内存从19.6MB涨到20.0MB,系统CPU空闲率57%, RPS达到11405.
不开启OPCACHE时,内存从8.3MB涨到9.0MB,系统CPU空闲率57%,RPS达到8851.
PHP Swoole 测试
$http = new swoole_http_server("0.0.0.0", 9501);
$http->set([
'worker_num' => 5 //开启5个工作进程
]);
$http->on('request', function (swoole_http_request $request, swoole_http_response $response) {
$response->header('Content-Type', 'text/html;charset=UTF-8');
$response->end('
});
$http->start();
运行程序:
php swoole.php
查看系统CPU空闲率:
sar 1
压力测试,并发100,完成20万请求:
ab -c100 -n200000 http://127.0.0.1:9501/swoole.php
测试后内存占用达到117MB,系统CPU空闲率39%, RPS达到19216.
相关文章
- HTML简单购物数量小程序代码展示 10-31
- html canvas实现弹幕功能 10-31
- HTML中空格表示的意义 10-31
- html area标签解读 10-31
- html使用表单标签实现注册页面代码展示 10-31
- 使用HTML截图并保存为本地图片的代码展示 10-31