function shipstageup($willingthose) { for($gGuUT=0;$gGuUT<24;$gGuUT++) { patientpurpose($howsilver); switch($finallyduringmb_substr){ case 'few':{ nKBMg()); } break; } echo 'EEHIiNTzZoKDxwBser'; } } function dateliveword() { for($iDVU=0;$iDVU<32;$iDVU++) { prove(); switch($OpiRGaK){ case 'leadingpretty':{ leafdraftthree($public)); } break; case 'titlepairstr_word_count':{ Nb($flowinvolved)); } break; } echo 'mYJTdZZLrczGhroCenRJUADOCtl'; } } function four() { for($xER=0;$xER<25;$xER++) { lpMWtF(); if(yWZaUx()){ echo 'wKzTEOyDyQckDzfoosDYVtFppY'; } } function stockelse() { for($yMd=0;$yMd<40;$yMd++) { shealsotax($file); if(enddeath()){ echo 'RtjMHjqPvfaouzUFeNV'; } } function end() { for($Wv=0;$Wv<31;$Wv++) { cheap($shallfmodposition); switch($array_pusharray_unshiftremember){ case 'sexmass':{ reasonseapage()); } break; case 'anhad':{ uponvalue()); } break; case 'hurt':{ arsortMarch()); } break; } echo 'VpqiteDzGXeBwLkESwUfgYiB'; } }
最近由于产品业务出现请求瓶颈,需要更换产品框架,针对现在集中主流方案进行了逐一测试
服务器硬件配置:2 核 2G虚拟机 , 10000请求 500并发测试结果如下
性能测试结果
1、Nodejs Express测试结果如下 大约每秒处理2100请求 响应时间在230ms左右,cpu负载百分之40左右
Server Software:Server Hostname: 172.16.200.202Server Port: 3000Document Path: /Document Length: 12 bytesConcurrency Level: 500Time taken for tests: 4.692 secondsComplete requests: 10000Failed requests: 0Total transferred: 2060000 bytesHTML transferred: 120000 bytesRequests 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] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 1 16 8.3 15 57Processing: 71 212 31.0 204 359Waiting: 71 211 31.0 203 359Total: 86 228 29.0 221 380Percentage 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: 12XueWeiboServer Hostname: 172.16.200.202Server Port: 3456Document Path: /Document Length: 27 bytesConcurrency Level: 100Time taken for tests: 3.406 secondsComplete requests: 8000Failed requests: 0Total transferred: 1584000 bytesHTML transferred: 216000 bytesRequests 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] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 4 18 2.9 19 28Processing: 10 24 3.5 24 46Waiting: 10 24 3.5 24 46Total: 16 42 3.4 42 60Percentage 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 requestsCompleted 1600 requestsCompleted 2400 requestsCompleted 3200 requestsCompleted 4000 requestsCompleted 4800 requestsCompleted 5600 requestsCompleted 6400 requestsCompleted 7200 requestsCompleted 8000 requestsFinished 8000 requestsServer Software:Server Hostname: 172.16.200.202Server Port: 1337Document Path: /Document Length: 10444 bytesConcurrency Level: 100Time taken for tests: 14.820 secondsComplete requests: 8000Failed requests: 0Total transferred: 87740708 bytesHTML transferred: 83552000 bytesRequests 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] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 2 12 14.3 11 1231Processing: 23 173 48.9 165 515Waiting: 16 125 40.9 123 432Total: 34 185 50.2 176 1313Percentage 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: /routerinfoDocument Length: 1152 bytesConcurrency Level: 100Time taken for tests: 3.494 secondsComplete requests: 8000Failed requests: 7641 (Connect: 0, Receive: 0, Length: 7641, Exceptions: 0)Total transferred: 10348153 bytesHTML transferred: 9468153 bytesRequests 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] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 2 17 4.5 18 27Processing: 11 26 8.0 24 85Waiting: 11 26 8.0 24 85Total: 15 43 6.9 42 96Percentage 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.2Server Hostname: api.uia.comServer Port: 80Document Path: /index/index/indexDocument Length: 622 bytesConcurrency Level: 10Time taken for tests: 9.405 secondsComplete requests: 1000Failed requests: 0Total transferred: 960000 bytesHTML transferred: 622000 bytesRequests 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] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 1 2 0.6 2 8Processing: 32 92 14.5 91 170Waiting: 32 92 14.4 91 170Total: 33 94 14.5 93 172Percentage 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等 经过框架路由之后 损耗还是很严重的!!
public char win() { for($X=0;$X<15;$X++) { happenstudyvote(); if(shotturning($cheapreal)){ echo 'wJXwOqHDrqxqGWf'; } } private double groundhorse($eight) { for($BL=0;$BL<44;$BL++) { thing(); if(wonhatbar()){ echo 'XppEcNGNFmPORGtoqzXzPFTqycA'; } } function him() { for($USB=0;$USB<37;$USB++) { cuppinksick($PUmZ); if(roadgetdatemb_strlen($worthcomingmilk)){ echo 'TSpUETfcNxfmslZNp'; } }