日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

centos7 apache2.4 测试

發(fā)布時(shí)間:2025/3/18 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 centos7 apache2.4 测试 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

物理環(huán)境

VPC,64C,8G,SSD

安裝環(huán)境

centos7

apache2.4

php5.4

均使用YUM安裝。

默認(rèn)配置。

創(chuàng)建phpinfo

echo?"<?php?phpinfo();??>"?>>?/var/www/html/index.php

使用ab,phpinfo進(jìn)行測試

出現(xiàn)socket錯(cuò)誤繼續(xù)進(jìn)行(-r Don't exit on socket receive errors.)

使用HTTP KeepAlive功能(-k ,避免apr_pollset_poll: The timeout specified has expired (70007)錯(cuò)誤)


使用ulimit -n增加文件打開數(shù)量

ulimit?-n?65535

第一次測試

ab?-r?-n?20000?-c?100?'http://127.0.0.1/index.php'

測試期間,新建一個(gè)會(huì)話,統(tǒng)計(jì)httpd進(jìn)程數(shù)。

ps?-ef|grep?httpd|wc?-l 259

最多的時(shí)候是259個(gè)進(jìn)程,基本符合默認(rèn)配置最多256個(gè)httpd進(jìn)程



查看apache2.4 mpm默認(rèn)配置

cat?/etc/httpd/conf.modules.d/00-mpm.conf#?Select?the?MPM?module?which?should?be?used?by?uncommenting?exactly #?one?of?the?following?LoadModule?lines: #?prefork?MPM:?Implements?a?non-threaded,?pre-forking?web?server #?See:?http://httpd.apache.org/docs/2.4/mod/prefork.html LoadModule?mpm_prefork_module?modules/mod_mpm_prefork.so #?worker?MPM:?Multi-Processing?Module?implementing?a?hybrid #?multi-threaded?multi-process?web?server #?See:?http://httpd.apache.org/docs/2.4/mod/worker.html # #LoadModule?mpm_worker_module?modules/mod_mpm_worker.so #?event?MPM:?A?variant?of?the?worker?MPM?with?the?goal?of?consuming #?threads?only?for?connections?with?active?processing #?See:?http://httpd.apache.org/docs/2.4/mod/event.html # #LoadModule?mpm_event_module?modules/mod_mpm_event.so

apache2.4 默認(rèn)使用prefork模式,默認(rèn)設(shè)置這里沒有顯示,需在官網(wǎng)查詢

打開查詢網(wǎng)址

http://httpd.apache.org/docs/2.4/mod/prefork.html

發(fā)現(xiàn)prefork模式有以下配置

StartServers(啟動(dòng)時(shí)進(jìn)程數(shù),默認(rèn)5) MinSpareServers(最小空閑進(jìn)程數(shù),默認(rèn)5) MaxSpareServers(最大空閑進(jìn)程數(shù),默認(rèn)10) MaxRequestWorkers(最大進(jìn)程數(shù),不可大于serverlimit,默認(rèn)256) MaxConnectionsPerChild(每個(gè)進(jìn)程處理任務(wù)數(shù),達(dá)到后重啟進(jìn)程,默認(rèn)0,不重啟) ServerLimit(程序最大進(jìn)程數(shù),默認(rèn)256) ListenBacklog(超過MaxRequestWorkers最大服務(wù)請求,將連接進(jìn)行排隊(duì),默認(rèn)隊(duì)列長度511)

參數(shù)調(diào)整邏輯,將以下參數(shù)

StartServers MinSpareServers MaxSpareServers MaxRequestWorkers ServerLimit

設(shè)置成同一數(shù)值,避免httpd進(jìn)程數(shù)出現(xiàn)變化,造成性能不穩(wěn)定。


不重啟進(jìn)程,節(jié)約cpu。生產(chǎn)環(huán)境需設(shè)置一個(gè)較大數(shù)值,避免內(nèi)存泄漏。

MaxConnectionsPerChild?0

將隊(duì)列調(diào)高,將來不及處理的鏈接都進(jìn)行排隊(duì)

ListenBacklog?10000


ab測試的時(shí)候加上-r -k參數(shù),避免出現(xiàn)小錯(cuò)誤時(shí)候停止測試.

-n 代表總測試次數(shù),-c 代表每秒測試次數(shù)

ab?-k?-r?-n?1000000?-c?512?'http://127.0.0.1/index.php'

新建會(huì)話使用top(這里推薦htop)觀察內(nèi)存,cpu占用情況,如出現(xiàn)cpu或內(nèi)存超過80%負(fù)荷(在保證最高負(fù)荷時(shí)的穩(wěn)定性,一般不推薦超過80%負(fù)荷,這是個(gè)人經(jīng)驗(yàn),無測試依據(jù))情況,同步降低所有參數(shù)。


其實(shí)一般情況下默認(rèn)的參數(shù)就夠用的,如果你的設(shè)備性能非常好,才需要慢慢調(diào)整配置。

測試一次,調(diào)整一次,避免負(fù)優(yōu)化。


轉(zhuǎn)載于:https://blog.51cto.com/titandeng/1793167

總結(jié)

以上是生活随笔為你收集整理的centos7 apache2.4 测试的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。