亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: Apache MPM worker中的幾個(gè)參數(shù) [打印本頁(yè)]

作者: dannyzhang    時(shí)間: 2011-12-21 08:44
標(biāo)題: Apache MPM worker中的幾個(gè)參數(shù)
      最近發(fā)現(xiàn)自己是個(gè)干雜活兒的人,因此把本博的名字都改成了“不求甚解”,純粹都為了解決眼前的問(wèn)題,這樣的工作方式已經(jīng)完完全全背離了自己的習(xí)慣。廢話少說(shuō),切入正題,最近對(duì)Apache中的一些參數(shù)做了些了解,下面就記錄一下我的理解。

  1. # worker MPM
  2. # ThreadLimit: maximum setting of ThreadsPerChild
  3. # ServerLimit: maximum setting of StartServers
  4. # StartServers: initial number of server processes to start
  5. # MaxClients: maximum number of simultaneous client connections
  6. # MinSpareThreads: minimum number of worker threads which are kept spare
  7. # MaxSpareThreads: maximum number of worker threads which are kept spare
  8. # ThreadsPerChild: constant number of worker threads in each server process
  9. # MaxRequestsPerChild: maximum number of requests a server process serves
  10. <IfModule worker.c>
  11. ThreadLimit 125
  12. ServerLimit 320
  13. StartServers 5
  14. MaxClients 8000
  15. MinSpareThreads 125
  16. MaxSpareThreads 1250
  17. ThreadsPerChild 125
  18. MaxRequestsPerChild 1000
  19. </IfModule>
其中最重要的參數(shù)是 ThreadsPerChild和 MaxClients:
  1. ##ThreadsPerChild 每個(gè)子進(jìn)程建立的線程數(shù),子進(jìn)程在啟動(dòng)時(shí)建立這些線程后就不再建立新的線程了
  2. ##MaxClients 允許同時(shí)伺服的最大接入請(qǐng)求數(shù)量(在worker下就是最大線程數(shù)量)
    1. ##ServerLimit:對(duì)最大子進(jìn)程數(shù)的上限,該值必須大于等于MaxClients/ThreadsPerChild
    2. ##ThreadLimit:對(duì)ThreadsPerChild的上限,該值必須大于等于 ThreadsPerChild,如果將ThreadLimit設(shè)置成一個(gè)高出實(shí)際需要很多的ThreadsPerChild值,將會(huì)有過(guò)多的共享內(nèi)存被 分配,應(yīng)當(dāng)和ThreadsPerChild可能達(dá)到的最大值保持一致.
    3. ##StartServers:服務(wù)器啟動(dòng)時(shí)的服務(wù)進(jìn)程數(shù)目,該值肯定小于等于ServerLimit
    4. ##MinSpareThreads和MaxSpareThreads:通過(guò)新建或結(jié)束子進(jìn)程的方式,將空閑線程的總數(shù)維持在這個(gè)范圍內(nèi)
    5. ##MaxRequestsPerChild:用于控制服務(wù)器建立新進(jìn)程和結(jié)束舊進(jìn)程的頻 率,其實(shí)是一個(gè)為了防止內(nèi)存溢出的參數(shù),每個(gè)子進(jìn)程在其生存期內(nèi)允許伺服的最大請(qǐng)求數(shù)量。到達(dá)MaxRequestsPerChild的限制后,子進(jìn)程將 會(huì)結(jié)束。對(duì)于KeepAlive鏈接,只有第一個(gè)請(qǐng)求會(huì)被計(jì)數(shù)。事實(shí)上,它改變了每個(gè)子進(jìn)程限制最大鏈接數(shù)量的行為。
    可以通過(guò)檢查HTTPServer/logs/error_log日志,判斷MaxClients是否需要增加,如果有下面的報(bào)錯(cuò),就說(shuō)明apache自上次重啟至今,曾經(jīng)發(fā)生過(guò)達(dá)到MaxClients的情況:

    1. Tue Jun 07 16:36:03 2011] [error] server reached MaxClients setting, consider raising the MaxClients setting
需要注意的是,這樣的報(bào)錯(cuò)并不會(huì)出現(xiàn)多次,當(dāng)?shù)诙芜_(dá)到MaxClients時(shí),error_log不會(huì)記錄。
還有一種可以實(shí)時(shí)看到連接數(shù)的方法,就是打開 server-status頁(yè)面,設(shè)置方法如下:
1. 去掉以下部分的注釋
  1. LoadModule status_module modules/mod_status.so
  2. <IfModule mod_status.c>
  3. ExtendedStatus On
  4. </IfModule>
2.修改以下部分
  1. <Location /server-status>
  2.     SetHandler server-status
  3.   # Order deny,allow
  4.   # Deny from all
  5.     Allow from all
  6. </Location>
重啟ihs
使用:http://yourhost/server-status 可以進(jìn)入監(jiān)控頁(yè)面
如果瀏覽器支持刷新,可以http://your_host/server-status?refresh=5 以便每 5 秒鐘刷新一次

在打開的監(jiān)控頁(yè)面中:"." Open slot with no current process,這里面的單個(gè)進(jìn)程的“.”的數(shù)量其實(shí)對(duì)應(yīng)與ThreadLimit這個(gè)值。
  1. <IfModule worker.c>
  2. ThreadLimit 10
  3. ServerLimit 2
  4. StartServers 1
  5. MaxClients 2
  6. MinSpareThreads 1
  7. MaxSpareThreads 2
  8. ThreadsPerChild 1
  9. MaxRequestsPerChild 1
  10. </IfModule>
httpd.conf的MPM配置如上例,在監(jiān)控頁(yè)面中的輸出如下,其中有2個(gè)進(jìn)程,各10個(gè)ThreadLimit,但由于ThreadsPerChild的限制,其實(shí)很多.是沒(méi)有用的。
  1. W........._.........





歡迎光臨 Chinaunix (http://www.72891.cn/) Powered by Discuz! X3.2