WEB頁(yè)面上萬(wàn)的并發(fā)

短板是帶寬

我當(dāng)時(shí)目標(biāo)很簡(jiǎn)單,如果我的網(wǎng)站能支撐1萬(wàn)個(gè)并發(fā) 在一分鐘內(nèi)處理完 就謝天謝地了。

經(jīng)過(guò)一輪的折騰之后,我得出的經(jīng)驗(yàn)是,上萬(wàn)的并發(fā)是有錢人的游戲,窮屌絲們只能在區(qū)域網(wǎng)里感嘆一下

因?yàn)?,木桶原理,短板在帶寬上,最燒錢的也是帶寬

假設(shè)站點(diǎn)的帶寬是4Mbit/s 請(qǐng)求的頁(yè)面大小是40kb,那么每秒只能處理的12個(gè)連接,一萬(wàn)個(gè)連接 要14分鐘

每秒僅處理12個(gè)連接。。。 你還對(duì)內(nèi)存有要求? 還是對(duì)CPU 有要求? 還是硬盤的讀寫速度跟不上了?還在乎用nginx還是apache?

Nginx 還是 Apache

大家都說(shuō)nginx 在并發(fā)上多么多么的有優(yōu)勢(shì),如果網(wǎng)站并發(fā)不超過(guò)2萬(wàn),親測(cè)Apache都稍優(yōu)于Nginx 再大我沒(méi)有測(cè)試過(guò),所以我現(xiàn)在很是后悔以前跟風(fēng)吹噓nginx好,epoll好。。。。

我在阿里云一個(gè)8G 4核 (Intel Xeon E5-2682v4 / Intel Xeon(Skylake) Platinum 8163 2.5 GHz)的服務(wù)器 同時(shí)搭建了Apache和Nginx環(huán)境 使用ab命令測(cè)試的

nginx 10000次381秒

Server Software:? ? ? ? nginx/1.12.2

Document Length:? ? ? ? 39281 bytes

Concurrency Level:? ? ? 10000

Time taken for tests:? 381.031 seconds

Complete requests:? ? ? 10000

Failed requests:? ? ? ? 0

Total transferred:? ? ? 395170000 bytes

HTML transferred:? ? ? 392810000 bytes

Requests per second:? ? 26.24 [#/sec] (mean)

Time per request:? ? ? 381030.615 [ms] (mean)

Time per request:? ? ? 38.103 [ms] (mean, across all concurrent requests)

Transfer rate:? ? ? ? ? 1012.80 [Kbytes/sec] received

Connection Times (ms)

? ? ? ? ? ? ? min? mean[+/-sd] median? max

Connect:? ? ? 26? 38? 24.2? ? 36? ? 1444

Processing:? 2114 192241 109289.0 193797? 380294

Waiting:? ? ? 28 190667 109446.4 192221? 378970

Total:? ? ? 2150 192279 109288.6 193832? 380321

Percentage of the requests served within a certain time (ms)

? 50%? 193832

? 66%? 252949

? 75%? 286462

? 80%? 304815

? 90%? 342882

? 95%? 362196

? 98%? 373041

? 99%? 376604

100%? 380321 (longest request)


Apache 10000次370秒

Server Software:? ? ? ? Apache/2.4.6

Document Length:? ? ? ? 39281 bytes

Concurrency Level:? ? ? 10000

Time taken for tests:? 369.933 seconds

Complete requests:? ? ? 10000

Failed requests:? ? ? ? 0

Total transferred:? ? ? 395460000 bytes

HTML transferred:? ? ? 392810000 bytes

Requests per second:? ? 27.03 [#/sec] (mean)

Time per request:? ? ? 369933.405 [ms] (mean)

Time per request:? ? ? 36.993 [ms] (mean, across all concurrent requests)

Transfer rate:? ? ? ? ? 1043.95 [Kbytes/sec] received

Connection Times (ms)

? ? ? ? ? ? ? min? mean[+/-sd] median? max

Connect:? ? ? 26? 36? 21.5? ? 36? ? 1436

Processing:? 2168 184588 105904.3 183677? 369183

Waiting:? ? ? 28 182993 106063.1 182085? 367833

Total:? ? ? 2204 184624 105904.7 183715? 369213

Percentage of the requests served within a certain time (ms)

? 50%? 183715

? 66%? 242029

? 75%? 274513

? 80%? 292806

? 90%? 333280

? 95%? 351313

? 98%? 362069

? 99%? 365738

100%? 369213 (longest request)

這數(shù)據(jù) 簡(jiǎn)直難以啟齒,沒(méi)錯(cuò) 我發(fā)現(xiàn)帶寬只有8M

那么高潮來(lái)了 我在阿里云的同區(qū)域網(wǎng)租了一臺(tái)服務(wù)器 同樣的環(huán)境 變成區(qū)域網(wǎng)內(nèi)測(cè)試了

Apache 20000 11秒 (1萬(wàn)的并發(fā)都不好意思來(lái)測(cè)試了)

Server Software:? ? ? ? Apache/2.4.6

Document Length:? ? ? ? 39281 bytes

Concurrency Level:? ? ? 20000

Time taken for tests:? 11.584 seconds

Complete requests:? ? ? 20000

Failed requests:? ? ? ? 0

Write errors:? ? ? ? ? 0

Total transferred:? ? ? 790920000 bytes

HTML transferred:? ? ? 785620000 bytes

Requests per second:? ? 1726.48 [#/sec] (mean)

Time per request:? ? ? 11584.234 [ms] (mean)

Time per request:? ? ? 0.579 [ms] (mean, across all concurrent requests)

Transfer rate:? ? ? ? ? 66675.35 [Kbytes/sec] received

Connection Times (ms)

? ? ? ? ? ? ? min? mean[+/-sd] median? max

Connect:? ? ? ? 0? 280 615.8? ? ? 0? ? 4567

Processing:? ? 0? 239 429.5? ? 155? ? 8174

Waiting:? ? ? ? 0? 149 254.0? ? 145? ? 8173

Total:? ? ? ? ? 1? 519 838.9? ? 164? 10153

Percentage of the requests served within a certain time (ms)

? 50%? ? 164

? 66%? ? 320

? 75%? ? 580

? 80%? 1110

? 90%? 1285

? 95%? 1928

? 98%? 3175

? 99%? 3879

100%? 10153 (longest request)

nginx 20000 11秒

Server Software:? ? ? ? nginx/1.12.2

Document Length:? ? ? ? 39281 bytes

Concurrency Level:? ? ? 20000

Time taken for tests:? 11.336 seconds

Complete requests:? ? ? 20000

Failed requests:? ? ? ? 0

Write errors:? ? ? ? ? 0

Total transferred:? ? ? 790340000 bytes

HTML transferred:? ? ? 785620000 bytes

Requests per second:? ? 1764.22 [#/sec] (mean)

Time per request:? ? ? 11336.451 [ms] (mean)

Time per request:? ? ? 0.567 [ms] (mean, across all concurrent requests)

Transfer rate:? ? ? ? ? 68082.72 [Kbytes/sec] received

Connection Times (ms)

? ? ? ? ? ? ? min? mean[+/-sd] median? max

Connect:? ? ? ? 0? 516? 34.8? ? 516? ? 574

Processing:? 572 3190 1618.7? 3463? 10669

Waiting:? ? ? ? 0? 754 906.9? ? 475? ? 6658

Total:? ? ? 1039 3705 1626.3? 4002? 11237

Percentage of the requests served within a certain time (ms)

? 50%? 4002

? 66%? 4622

? 75%? 4964

? 80%? 5134

? 90%? 5436

? 95%? 5849

? 98%? 6860

? 99%? 7325

100%? 11237 (longest request)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容