最近由于产品业务出现请求瓶颈,需要更换产品框架,针对现在集中主流方案进行了逐一测试
服务器硬件配置:2 核 2G虚拟机 , 10000请求 500并发测试结果如下
性能测试结果
1、Nodejs Express测试结果如下 大约每秒处理2100请求 响应时间在230ms左右,cpu负载百分之40左右
Server Software: Server Hostname: 172.16.200.202 Server Port: 3000 Document Path: / Document Length: 12 bytes Concurrency Level: 500 Time taken for tests: 4.692 seconds Complete requests: 10000 Failed requests: 0 Total transferred: 2060000 bytes HTML transferred: 120000 bytes Requests per second: 2131.47 [#/sec] (mean) Time per request: 234.580 [ms] (mean) Time per request: 0.469 [ms] (mean, across all concurrent requests) Transfer rate: 428.79 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 1 16 8.3 15 57 Processing: 71 212 31.0 204 359 Waiting: 71 211 31.0 203 359 Total: 86 228 29.0 221 380 Percentage of the requests served within a certain time (ms) 50% 221 66% 230 75% 241 80% 248 90% 258 95% 291 98% 302 99% 304 100% 380 (longest request)
2、PHP7+Swoole 秒处理请求2300 响应时间40s左右 cpu只占用了15%
Server Software: 12XueWeibo Server Hostname: 172.16.200.202 Server Port: 3456 Document Path: / Document Length: 27 bytes Concurrency Level: 100 Time taken for tests: 3.406 seconds Complete requests: 8000 Failed requests: 0 Total transferred: 1584000 bytes HTML transferred: 216000 bytes Requests per second: 2348.89 [#/sec] (mean) Time per request: 42.573 [ms] (mean) Time per request: 0.426 [ms] (mean, across all concurrent requests) Transfer rate: 454.18 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 4 18 2.9 19 28 Processing: 10 24 3.5 24 46 Waiting: 10 24 3.5 24 46 Total: 16 42 3.4 42 60 Percentage of the requests served within a certain time (ms) 50% 42 66% 44 75% 44 80% 45 90% 46 95% 48 98% 49 99% 51 100% 60 (longest request)
3、Nodejs Sails 每秒处理500左右请求 每个请求响应用掉190ms 时间 cpu 百分之50左右
Benchmarking 172.16.200.202 (be patient) Completed 800 requests Completed 1600 requests Completed 2400 requests Completed 3200 requests Completed 4000 requests Completed 4800 requests Completed 5600 requests Completed 6400 requests Completed 7200 requests Completed 8000 requests Finished 8000 requests Server Software: Server Hostname: 172.16.200.202 Server Port: 1337 Document Path: / Document Length: 10444 bytes Concurrency Level: 100 Time taken for tests: 14.820 seconds Complete requests: 8000 Failed requests: 0 Total transferred: 87740708 bytes HTML transferred: 83552000 bytes Requests per second: 539.81 [#/sec] (mean) Time per request: 185.249 [ms] (mean) Time per request: 1.852 [ms] (mean, across all concurrent requests) Transfer rate: 5781.69 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 2 12 14.3 11 1231 Processing: 23 173 48.9 165 515 Waiting: 16 125 40.9 123 432 Total: 34 185 50.2 176 1313 Percentage of the requests served within a certain time (ms) 50% 176 66% 179 75% 181 80% 184 90% 239 95% 298 98% 343 99% 362 100% 1313 (longest request)
4、golang Beego 每秒大约处理2400个请求 每个请求响应时间45ms cpu 百分之15左右
Document Path: /routerinfo Document Length: 1152 bytes Concurrency Level: 100 Time taken for tests: 3.494 seconds Complete requests: 8000 Failed requests: 7641 (Connect: 0, Receive: 0, Length: 7641, Exceptions: 0) Total transferred: 10348153 bytes HTML transferred: 9468153 bytes Requests per second: 2289.46 [#/sec] (mean) Time per request: 43.678 [ms] (mean) Time per request: 0.437 [ms] (mean, across all concurrent requests) Transfer rate: 2892.06 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 2 17 4.5 18 27 Processing: 11 26 8.0 24 85 Waiting: 11 26 8.0 24 85 Total: 15 43 6.9 42 96 Percentage of the requests served within a certain time (ms) 50% 42 66% 44 75% 46 80% 46 90% 49 95% 54 98% 64 99% 71 100% 96 (longest request)
5、 ThinkPHP 请求量缩减10倍1000, 并发量缩减50倍10,结果如下 每秒106请求 平均响应时间 94ms ,目前api就是用的此框架 果断需要更换了
Server Software: Tengine/2.1.2 Server Hostname: api.uia.com Server Port: 80 Document Path: /index/index/index Document Length: 622 bytes Concurrency Level: 10 Time taken for tests: 9.405 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 960000 bytes HTML transferred: 622000 bytes Requests per second: 106.33 [#/sec] (mean) Time per request: 94.047 [ms] (mean) Time per request: 9.405 [ms] (mean, across all concurrent requests) Transfer rate: 99.68 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 1 2 0.6 2 8 Processing: 32 92 14.5 91 170 Waiting: 32 92 14.4 91 170 Total: 33 94 14.5 93 172 Percentage of the requests served within a certain time (ms) 50% 93 66% 99 75% 103 80% 105 90% 111 95% 117 98% 126 99% 133 100% 172 (longest request)
很显然从结果看来 Sails、ThinkPHP等 经过框架路由之后 损耗还是很严重的!!