centos7 apache2.4 测试
物理環(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)行測(cè)試
出現(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增加文件打開(kāi)數(shù)量
ulimit?-n?65535第一次測(cè)試
ab?-r?-n?20000?-c?100?'http://127.0.0.1/index.php'測(cè)試期間,新建一個(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.soapache2.4 默認(rèn)使用prefork模式,默認(rèn)設(shè)置這里沒(méi)有顯示,需在官網(wǎng)查詢(xún)
打開(kāi)查詢(xún)網(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(超過(guò)MaxRequestWorkers最大服務(wù)請(qǐng)求,將連接進(jìn)行排隊(duì),默認(rèn)隊(duì)列長(zhǎng)度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)高,將來(lái)不及處理的鏈接都進(jìn)行排隊(duì)
ListenBacklog?10000ab測(cè)試的時(shí)候加上-r -k參數(shù),避免出現(xiàn)小錯(cuò)誤時(shí)候停止測(cè)試.
-n 代表總測(cè)試次數(shù),-c 代表每秒測(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)存超過(guò)80%負(fù)荷(在保證最高負(fù)荷時(shí)的穩(wěn)定性,一般不推薦超過(guò)80%負(fù)荷,這是個(gè)人經(jīng)驗(yàn),無(wú)測(cè)試依據(jù))情況,同步降低所有參數(shù)。
其實(shí)一般情況下默認(rèn)的參數(shù)就夠用的,如果你的設(shè)備性能非常好,才需要慢慢調(diào)整配置。
測(cè)試一次,調(diào)整一次,避免負(fù)優(yōu)化。
轉(zhuǎn)載于:https://blog.51cto.com/titandeng/1793167
總結(jié)
以上是生活随笔為你收集整理的centos7 apache2.4 测试的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【转载】解决Windows和Ubuntu
- 下一篇: JFrame中使用jpanel来布局