taoCMS是基于php+sqlite/mysql的国内最小(100Kb左右)的功能完善的CMS管理系统

PHP vs Node.js vs Nginx-Lua

2016-08-07

PHP vs Node.js vs Nginx-Lua

2013-01-04/emptyhua@gmail.com

ENV

Server

Red Hat Enterprise Linux Server release 6.2 (Santiago)
CPU:Intel(R) Xeon(R) X5680 3.33GHz X 24
MEM:24G

Client

Red Hat Enterprise Linux Server release 6.2 (Santiago)
CPU:AMD Opteron(tm) Processor 4280 X 16
MEM:32G

Software

openresty 1.2.4.14
PHP 5.3.6
node.js v0.8.16
ab 2.3 

Scripts

hello.php

<?php
echo "hello worldn";
?>

bench.hello.js

var http = require('http');

function server_start() {
    http.createServer(function (req, res) {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('hello worldn');
    }).listen(8080);
}


var cluster = require('cluster');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
    for (var i = 0; i < numCPUs; i++) {
        cluster.fork();
    }
} else {
    server_start();
}

nginx.conf

location /lua_hello {
    content_by_lua '
        ngx.say("hello world")
    ';
}

Commands

curl "http://192.168.99.93:9999/start?group=php.node.lua&name=php-fpm&pgrep=php-fpm,worker%20process&iface=eth1/out"
sleep 6
ab -n 10000000 -c 100 http://192.168.99.93/hello.php
curl "http://192.168.99.93:9999/stop?group=php.node.lua&name=php-fpm"

curl "http://192.168.99.93:9999/start?group=php.node.lua&name=node.js&pgrep=bench.hello.js&iface=eth1/out"
sleep 6
ab -n 10000000 -c 100 http://192.168.99.93:8080/get
curl "http://192.168.99.93:9999/stop?group=php.node.lua&name=node.js"

curl "http://192.168.99.93:9999/start?group=php.node.lua&name=nginx-lua&pgrep=worker%20process&iface=eth1/out"
sleep 6
ab -n 10000000 -c 100 http://192.168.99.93/lua_hello
curl "http://192.168.99.93:9999/stop?group=php.node.lua&name=nginx-lua"

Results

PHP

Server Software: ngx_openresty/1.2.4.14
Server Hostname: 192.168.99.93
Server Port: 80

Document Path: /hello.php
Document Length: 12 bytes

Concurrency Level: 100
Time taken for tests: 574.692 seconds
Complete requests: 10000000
Failed requests: 0
Write errors: 0
Total transferred: 1690000676 bytes
HTML transferred: 120000048 bytes
Requests per second: 17400.61 [#/sec] (mean)
Time per request: 5.747 [ms] (mean)
Time per request: 0.057 [ms] (mean, across all concurrent requests)
Transfer rate: 2871.78 [Kbytes/sec] received

Connection Times (ms)
              min mean[+/-sd] median max
Connect: 0 1 0.9 1 6
Processing: 0 4 1.9 4 125
Waiting: 0 4 1.7 4 124
Total: 0 6 2.0 6 127

Percentage of the requests served within a certain time (ms)
  50% 6
  66% 6
  75% 7
  80% 7
  90% 8
  95% 9
  98% 11
  99% 11
 100% 127 (longest request)

Node.js

Server Software:        
Server Hostname: 192.168.99.93
Server Port: 8080

Document Path: /get
Document Length: 12 bytes

Concurrency Level: 100
Time taken for tests: 320.541 seconds
Complete requests: 10000000
Failed requests: 0
Write errors: 0
Total transferred: 1130001017 bytes
HTML transferred: 120000108 bytes
Requests per second: 31197.23 [#/sec] (mean)
Time per request: 3.205 [ms] (mean)
Time per request: 0.032 [ms] (mean, across all concurrent requests)
Transfer rate: 3442.67 [Kbytes/sec] received

Connection Times (ms)
              min mean[+/-sd] median max
Connect: 0 2 59.7 1 9001
Processing: 0 1 3.8 1 610
Waiting: 0 1 3.8 1 610
Total: 0 3 59.8 2 9002

Percentage of the requests served within a certain time (ms)
  50% 2
  66% 2
  75% 2
  80% 2
  90% 3
  95% 3
  98% 3
  99% 4
 100% 9002 (longest request)

Nginx-Lua

Server Software: ngx_openresty/1.2.4.14
Server Hostname: 192.168.99.93
Server Port: 80

Document Path: /lua_hello
Document Length: 12 bytes

Concurrency Level: 100
Time taken for tests: 306.482 seconds
Complete requests: 10000000
Failed requests: 0
Write errors: 0
Total transferred: 1790002864 bytes
HTML transferred: 120000192 bytes
Requests per second: 32628.32 [#/sec] (mean)
Time per request: 3.065 [ms] (mean)
Time per request: 0.031 [ms] (mean, across all concurrent requests)
Transfer rate: 5703.59 [Kbytes/sec] received

Connection Times (ms)
              min mean[+/-sd] median max
Connect: 0 1 2.1 1 3001
Processing: 1 2 0.6 2 98
Waiting: 0 1 0.6 1 98
Total: 1 3 2.2 3 3003

Percentage of the requests served within a certain time (ms)
  50% 3
  66% 3
  75% 3
  80% 3
  90% 3
  95% 3
  98% 3
  99% 4
 100% 3003 (longest request)

System load

ZoomstartCPUeventsnginx-luanode.jsphp-fpm9分49秒9分19秒5分19秒5分49秒6分19秒6分49秒7分19秒7分49秒8分19秒8分49秒05001,0001,5001M5MAllHighcharts.com
ZoomstartMEMeventsnginx-luanode.jsphp-fpm49秒1分49秒2分49秒3分49秒4分49秒5分49秒6分49秒7分49秒8分49秒9分49秒0KB488.28MB976.56MB1.43GB1M5MAllnginx-lua: MEM:288.00MB process count:24node.jsMEM:600.00MB process count:25php-fpmMEM:792.00MB process count:66Highcharts.com
ZoomstartNETeventsnginx-luanode.jsphp-fpm49秒1分49秒2分49秒3分49秒4分49秒5分49秒6分49秒7分49秒8分49秒9分49秒0KB9.54MB19.07MB1M5MAllHighcharts.com

类别:未分组 | 阅读:184961 | 评论:456 | 标签:

想收藏或者和大家分享这篇好文章→

“PHP vs Node.js vs Nginx-Lua”共有0条留言

发表评论

姓名:

邮箱:

网址:

验证码:

公告

taoCMS发布taoCMS 3.0.2(最后更新21年03月15日),请大家速速升级,欢迎大家试用和提出您宝贵的意见建议。

捐助与联系

☟请使用新浪微博联系我☟

☟在github上follow我☟

标签云