Last active
August 29, 2015 14:16
-
-
Save sidorares/5f90ecb853c902786338 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cluster = require('cluster'); | |
var http = require('http'); | |
var numCPUs = require('os').cpus().length; | |
if (cluster.isMaster) { | |
// Fork workers. | |
for (var i = 0; i < numCPUs; i++) { | |
cluster.fork(); | |
} | |
cluster.on('exit', function(worker, code, signal) { | |
console.log('worker ' + worker.process.pid + ' died'); | |
}); | |
} else { | |
var mysql = require('mysql'); | |
//var mysql = require('mysql2'); | |
var connection = mysql.createPool({ | |
host : 'localhost', | |
user : 'root', | |
password: '', | |
database: 'test' | |
}); | |
var strQuery = 'select * from insert_test limit 100'; | |
http.createServer(function (req, res) { | |
connection.query( strQuery, function(err, rows){ | |
if(err) { | |
res.writeHead(502); | |
return res.end(); | |
} | |
var data = JSON.stringify(rows); | |
res.writeHead(200, {'Content-Type': 'application/json;charset=utf-8','Content-Length':data.length}); | |
res.end(data); | |
}); | |
}).listen(9615); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":1,"title":"test abc xyz"},{"id":2,"title":"test abc xyz"},{"id":3,"title":"test abc xyz"},{"id":4,"title":"test abc xyz"},{"id":5,"title":"test abc xyz"},{"id":6,"title":"test abc xyz"},{"id":7,"title":"test abc xyz"},{"id":8,"title":"test abc xyz"},{"id":9,"title":"test abc xyz"},{"id":10,"title":"test abc xyz"},{"id":11,"title":"test abc xyz"},{"id":12,"title":"test abc xyz"},{"id":13,"title":"test abc xyz"},{"id":14,"title":"test abc xyz"},{"id":15,"title":"test abc xyz"},{"id":16,"title":"test abc xyz"},{"id":17,"title":"test abc xyz"},{"id":18,"title":"test abc xyz"},{"id":19,"title":"test abc xyz"},{"id":20,"title":"test abc xyz"},{"id":21,"title":"test abc xyz"},{"id":22,"title":"test abc xyz"},{"id":23,"title":"test abc xyz"},{"id":24,"title":"test abc xyz"},{"id":25,"title":"test abc xyz"},{"id":26,"title":"test abc xyz"},{"id":27,"title":"test abc xyz"},{"id":28,"title":"test abc xyz"},{"id":29,"title":"test abc xyz"},{"id":30,"title":"test abc xyz"},{"id":31,"title":"test abc xyz"},{"id":32,"title":"test abc xyz"},{"id":33,"title":"test abc xyz"},{"id":34,"title":"test abc xyz"},{"id":35,"title":"test abc xyz"},{"id":36,"title":"test abc xyz"},{"id":37,"title":"test abc xyz"},{"id":38,"title":"test abc xyz"},{"id":39,"title":"test abc xyz"},{"id":40,"title":"test abc xyz"},{"id":41,"title":"test abc xyz"},{"id":42,"title":"test abc xyz"},{"id":43,"title":"test abc xyz"},{"id":44,"title":"test abc xyz"},{"id":45,"title":"test abc xyz"},{"id":46,"title":"test abc xyz"},{"id":47,"title":"test abc xyz"},{"id":48,"title":"test abc xyz"},{"id":49,"title":"test abc xyz"},{"id":50,"title":"test abc xyz"},{"id":51,"title":"test abc xyz"},{"id":52,"title":"test abc xyz"},{"id":53,"title":"test abc xyz"},{"id":54,"title":"test abc xyz"},{"id":55,"title":"test abc xyz"},{"id":56,"title":"test abc xyz"},{"id":57,"title":"test abc xyz"},{"id":58,"title":"test abc xyz"},{"id":59,"title":"test abc xyz"},{"id":60,"title":"test abc xyz"},{"id":61,"title":"test abc xyz"},{"id":62,"title":"test abc xyz"},{"id":63,"title":"test abc xyz"},{"id":64,"title":"test abc xyz"},{"id":65,"title":"test abc xyz"},{"id":66,"title":"test abc xyz"},{"id":67,"title":"test abc xyz"},{"id":68,"title":"test abc xyz"},{"id":69,"title":"test abc xyz"},{"id":70,"title":"test abc xyz"},{"id":71,"title":"test abc xyz"},{"id":72,"title":"test abc xyz"},{"id":73,"title":"test abc xyz"},{"id":74,"title":"test abc xyz"},{"id":75,"title":"test abc xyz"},{"id":76,"title":"test abc xyz"},{"id":77,"title":"test abc xyz"},{"id":78,"title":"test abc xyz"},{"id":79,"title":"test abc xyz"},{"id":80,"title":"test abc xyz"},{"id":81,"title":"test abc xyz"},{"id":82,"title":"test abc xyz"},{"id":83,"title":"test abc xyz"},{"id":84,"title":"test abc xyz"},{"id":85,"title":"test abc xyz"},{"id":86,"title":"test abc xyz"},{"id":87,"title":"test abc xyz"},{"id":88,"title":"test abc xyz"},{"id":89,"title":"test abc xyz"},{"id":90,"title":"test abc xyz"},{"id":91,"title":"test abc xyz"},{"id":92,"title":"test abc xyz"},{"id":93,"title":"test abc xyz"},{"id":94,"title":"test abc xyz"},{"id":95,"title":"test abc xyz"},{"id":96,"title":"test abc xyz"},{"id":97,"title":"test abc xyz"},{"id":98,"title":"test abc xyz"},{"id":99,"title":"test abc xyz"},{"id":100,"title":"test abc xyz"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP: | |
wrk -t 10 -c 100 -d 100s http://localhost/test.php | |
Running 2m test @ http://localhost/phpinfo.php | |
10 threads and 100 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 23.43s 8.62s 26.72s 88.03% | |
Req/Sec 54.58 161.55 2.44k 90.55% | |
49016 requests in 1.67m, 161.74MB read | |
Socket errors: connect 0, read 1, write 0, timeout 3719 | |
Requests/sec: 489.85 | |
Transfer/sec: 1.62MB | |
node-mysql ( no pool, no cluster ): | |
wrk -t 10 -c 100 -d 100s http://localhost:9615/ | |
Running 2m test @ http://localhost:9615/ | |
10 threads and 100 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 62.56ms 32.67ms 322.64ms 88.80% | |
Req/Sec 178.97 49.81 265.00 66.73% | |
178818 requests in 1.67m, 586.81MB read | |
Requests/sec: 1787.58 | |
Transfer/sec: 5.87MB | |
node-mysql ( pool, no cluster ) | |
wrk -t 10 -c 100 -d 100s http://localhost:9615/ | |
Running 2m test @ http://localhost:9615/ | |
10 threads and 100 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 52.18ms 7.50ms 150.86ms 92.91% | |
Req/Sec 193.32 19.40 238.00 81.82% | |
193072 requests in 1.67m, 633.58MB read | |
Requests/sec: 1930.28 | |
Transfer/sec: 6.33MB | |
node-mysql ( pool, cluster ) | |
wrk -t 10 -c 100 -d 100s http://localhost:9615/ | |
Running 2m test @ http://localhost:9615/ | |
10 threads and 100 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 32.88ms 16.10ms 196.81ms 86.46% | |
Req/Sec 313.96 46.67 466.00 74.32% | |
313421 requests in 1.67m, 1.00GB read | |
Requests/sec: 3134.02 | |
Transfer/sec: 10.28MB | |
node-mysql2 ( no pool, no cluster ): | |
wrk -t 10 -c 100 -d 100s http://localhost:9615/ | |
Running 2m test @ http://localhost:9615/ | |
10 threads and 100 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 37.88ms 31.02ms 376.29ms 94.54% | |
Req/Sec 308.54 86.07 500.00 72.69% | |
306661 requests in 1.67m, 0.98GB read | |
Requests/sec: 3065.67 | |
Transfer/sec: 10.06MB | |
node-mysql2 ( pool, no cluster ): | |
wrk -t 10 -c 100 -d 100s http://localhost:9615/ | |
Running 2m test @ http://localhost:9615/ | |
10 threads and 100 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 27.27ms 10.80ms 152.05ms 92.17% | |
Req/Sec 392.61 80.70 561.00 72.86% | |
390486 requests in 1.67m, 1.25GB read | |
Requests/sec: 3904.36 | |
Transfer/sec: 12.81MB | |
node-mysql2 ( pool, cluster ): | |
wrk -t 10 -c 100 -d 100s http://localhost:9615/ | |
Running 2m test @ http://localhost:9615/ | |
10 threads and 100 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 26.17ms 26.67ms 274.85ms 89.10% | |
Req/Sec 447.88 148.30 846.00 63.82% | |
445735 requests in 1.67m, 1.43GB read | |
Requests/sec: 4457.24 | |
Transfer/sec: 14.63MB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment