httpd IO相應(yīng)進(jìn)程數(shù)調(diào)優(yōu)

目的:在機(jī)器能夠承受情況下,達(dá)到最大請(qǐng)求連接數(shù)

概念:http的IO模式

prefork, worker, event,其中prefork為進(jìn)程模式,worker和event為線程的多路復(fù)用模式,本文以httpd傳統(tǒng)的prefork為例,也可以通過(guò)更改配置文件設(shè)置httpd的IO響應(yīng)模式

/etc/httpd/conf.modules.d/00-mpm.conf

準(zhǔn)備測(cè)試網(wǎng)頁(yè)

一般一個(gè)5Mb大小的文本文件test.txt,通常門口網(wǎng)站主頁(yè)大小,

  1. 調(diào)整prefork的配置,從2000個(gè)進(jìn)程開(kāi)始
StartServers 2000
MinSpareServers 5
MaxSpareServers 20
ServerLimit 2000                     # 最多進(jìn)程數(shù),最大值 20000
MaxClients 2000                     # 最大的并發(fā)連接數(shù)
MaxRequestsPerChild 4000       # 子進(jìn)程最多能處理的請(qǐng)求數(shù)量。

在服務(wù)端打開(kāi)vmstate

vmstat 1 #主要觀察內(nèi)存和swap情況

在client端測(cè)試httpd連接狀況,根據(jù)測(cè)試結(jié)果不斷調(diào)整profork進(jìn)程數(shù)大小

# ab命令為httpd-tools中的一個(gè)工具
# 輸出中主要的參數(shù)為Requests per second
ab -c1000 -n2000 http://ip/test.txt
Document Path:          /
Document Length:        20 bytes

Concurrency Level:      10
Time taken for tests:   0.070 seconds
Complete requests:      10
Failed requests:        0
Write errors:           0
Total transferred:      2650 bytes
HTML transferred:       200 bytes
Requests per second:    143.24 [#/sec] (mean)
Time per request:       69.813 [ms] (mean)
Time per request:       6.981 [ms] (mean, across all concurrent requests)
Transfer rate:          37.07 [Kbytes/sec] received


最后編輯于
?著作權(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ù)。

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