我经常听到别人的node.js本机的hello world程序可以跑到10000/s的数据,可我在我的2014 新的macpro机子上跑,怎么只能拿到1400/s的数据?
ulimit:
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-v: address space (kbytes) unlimited
-l: locked-in-memory size (kbytes) unlimited
-u: processes 709
-n: file descriptors 9999
helloworld.js
// Load the http module to create an http server.
var http = require('http');
http.globalAgent.maxSockets = 2000;
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");
性能测试工具wrk
wrk -t8 -c800 -d30s http://localhost:8000/
测试结果:
Running 30s test @ http://localhost:8000/
8 threads and 800 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 71.76ms 32.52ms 191.40ms 81.79%
Req/Sec 1.41k 527.68 4.00k 70.22%
333705 requests in 30.00s, 49.65MB read
Socket errors: connect 0, read 958, write 0, timeout 797
为什么 结果这么渣渣?达人请指点指点!谢谢!!