分别对三种情况进行了压力测试,程序是执行一条mysql语句 工具:ab 一共1000的请求,每秒100个并发 ,测试结果如下: 1、没做处理的
Concurrency Level: 100 Time taken for tests: 3.234 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 299000 bytes HTML transferred: 224000 bytes Requests per second: 309.18 [#/sec] (mean) Time per request: 323.438 [ms] (mean) Time per request: 3.234 [ms] (mean, across all concurrent requests) Transfer rate: 90.28 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 2.5 0 16 Processing: 63 310 53.9 313 500 Waiting: 63 308 54.0 297 500 Total: 63 311 53.9 313 500 Percentage of the requests served within a certain time (ms) 50% 313 66% 313 75% 328 80% 344 90% 375 95% 406 98% 438 99% 469 100% 500 (longest request)
2、用了cluster 双核cpu
Concurrency Level: 100 Time taken for tests: 3.266 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 299000 bytes HTML transferred: 224000 bytes Requests per second: 306.22 [#/sec] (mean) Time per request: 326.563 [ms] (mean) Time per request: 3.266 [ms] (mean, across all concurrent requests) Transfer rate: 89.41 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 2.8 0 16 Processing: 141 303 41.1 313 391 Waiting: 125 300 42.1 313 391 Total: 141 303 41.0 313 391 Percentage of the requests served within a certain time (ms) 50% 313 66% 313 75% 328 80% 328 90% 344 95% 359 98% 359 99% 375 100% 391 (longest request)
3、用了pool连接池 最大连接数100 30秒超时,每次请求后释放
Concurrency Level: 100 Time taken for tests: 4.969 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 299000 bytes HTML transferred: 224000 bytes Requests per second: 201.26 [#/sec] (mean) Time per request: 496.875 [ms] (mean) Time per request: 4.969 [ms] (mean, across all concurrent requests) Transfer rate: 58.77 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 2.9 0 16 Processing: 234 482 122.2 453 1000 Waiting: 109 371 119.7 344 891 Total: 234 482 122.2 453 1000 Percentage of the requests served within a certain time (ms) 50% 453 66% 469 75% 469 80% 500 90% 563 95% 859 98% 922 99% 984 100% 1000 (longest request)
为啥第二种与第一种几乎一样,第三种最差呢?
这个要看代码怎么写的,用了什么驱动,还有数据库是不是限制连接已经达到瓶劲了
就一条语句
_db.query('SELECT id,title FROM `blog_article` ', function(err, results, fields){
res.write(JSON.stringify(results));
res.end();
});
mysql设置的最大连接数为100
3种测试结果指向一个结论:测定的瓶颈在于mysql的IO读取。cluster对于减少mysql的io访问时间毫无帮助;每次请求后释放则需要重新连接mysql,增加mysql的io访问时间。
路过~