wangmingda 回復于:2004-04-30 13:21:49 |
在Apache2.0中新加入了ServerLimit指令,使得無須重編譯Apache就可以加大MaxClients。下面是筆者的prefork配置段。
<IfModule prefork.c> StartServers 10 MinSpareServers 10 MaxSpareServers 15 ServerLimit 2000 MaxClients 1500 MaxRequestsPerChild 10000 </IfModule> BTW: ServerLimit的最大值是20000,這對于大多數站點是足夠了,但如果你一定要再加大的話,那么這個值位于源代碼樹下的server/mpm/prefork/prefork.c中。里面的 #define DEFAULT_SERVER_LIMIT 256 #define MAX_SERVER_LIMIT 20000 這兩行就對應著MaxClients和ServerLimit的限制值。但我相信很少有人可以用到20000的并發連接數。 如果你有耐性看完了我這篇文檔,我相信您對Apache2.0 缺省的prefork的工作原理有所熟悉了,理解了它的工作過程后,就可以根據您的實際情況在FreeBSD下來配置Apache相關的核心參數以獲得最大的性能。 |
rickyfang 回復于:2004-04-30 14:58:23 |
無限感激中,原以為我已看懂了APACHE 2.0.48的說明文檔,而且檢查語法時,也出面ServerLimi 我竟沒有耐心去找到它。唉。謝謝大哥?。?!
BTW:按你的提示,我已搞定,解決了困惑很久的問題。 |
wangbin 回復于:2004-05-26 22:57:48 |
http://xcdx.enhand.net/viewthread.php?tid=3260 |
rickyfang 回復于:2004-05-27 21:49:42 |
謝過,只是我也有找到相關的網址呢,不錯的說,讓我對此有了更深的認識,而且我已成功的做成了。
想說,大家有時間的話,有些聯系方式可以嗎,組成共同的愛好者,為了我們的工作和愛好,努力一回吧! |
rickyfang 回復于:2004-05-30 16:34:55 |
有時想找幾個志同道合者,可是,卻沒有人回應啊。QQ45723305 :( |
peng 回復于:2004-06-01 16:04:21 |
其實用apache2的話,./configure中應該用--with-mpm=worker參數,這樣才能發揮apache2的多線程機制。
vi ~apache_install_path/conf/httpd.conf IfModule worker.c> StartServers 2 MaxClients 150 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0 </IfModule> MaxClients x ThreadsPerChild =響應的請求數,可以根據自己的實際情況,更改threadsperchild數目。 對于linux下,其實不能實現多線程模式,要加大MaxClients 的數目,solaris下,就非常優秀了。。 wangmingda 說的也很正確,他是apache2編譯的時候采用了默認的 --with-mpm=prefork模式,這種模式是兼容舊的軟件版本的,不能更好的發揮apache2的線成特性。 本人對apache看的也很糙,希望和大家討論。 |
rickyfang 回復于:2004-06-20 21:09:59 |
根據這位仁兄的說法,我做了兩臺服務器,一個是PREFORK的模式,一個是WORKER的工作模式,用MRTG做的流量監控,可能防問用戶數量的問題,不是太明顯,不過也感受了新的變化,謝過,請多交流吧? |
jackieyuan 回復于:2004-11-18 18:27:18 |
[quote:97d4083bdd="peng"]其實用apache2的話,./configure中應該用--with-mpm=worker參數,這樣才能發揮apache2的多線程機制。
vi ~apache_install_path/conf/httpd.conf IfModule worker.c> StartServers 2 MaxClients ..........[/quote:97d4083bdd] [quote:97d4083bdd]Compile-Time Configuration Issues Choosing an MPM Apache 2.x supports pluggable concurrency models, called Multi-Processing Modules (MPMs). When building Apache, you must choose an MPM to use. There are platform-specific MPMs for some platforms: beos, mpm_netware, mpmt_os2, and mpm_winnt. For general Unix-type systems, there are several MPMs from which to choose. The choice of MPM can affect the speed and scalability of the httpd: The worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time. Worker generally is a good choice for high-traffic servers because it has a smaller memory footprint than the prefork MPM. The prefork MPM uses multiple child processes with one thread each. Each process handles one connection at a time. On many systems, prefork is comparable in speed to worker, but it uses more memory. Prefork's threadless design has advantages over worker in some situations: it can be used with non-thread-safe third-party modules, and it is easier to debug on platforms with poor thread debugging support. For more information on these and other MPMs, please see the MPM documentation.[/quote:97d4083bdd] http://httpd.apache.org/docs-2.0/misc/perf-tuning.html#compiletime :em02: :em02: |
jackieyuan 回復于:2004-11-18 23:30:02 |
[quote:25fcfbfbfb="peng"]其實用apache2的話,./configure中應該用--with-mpm=worker參數,這樣才能發揮apache2的多線程機制。
vi ~apache_install_path/conf/httpd.conf IfModule worker.c> StartServers 2 MaxClients ..........[/quote:25fcfbfbfb] 因為在設置的時候出現錯誤,所以把我的想法說說看。 設置 [code:1:25fcfbfbfb]ServerLimit 8 StartServers 2 MinSpareThreads 15 MaxSpareThreads 25 ThreadsPerChild 25 MaxRequestsPerChild 1000 MaxClients 250[/code:1:25fcfbfbfb] 錯誤: [code:1:25fcfbfbfb]WARNING: MaxClients of 250 would require 10 servers, and would exceed the ServerLimit value of 8. Automatically lowering MaxClients to 200. To increase, please see the ServerLimit directive.[/code:1:25fcfbfbfb] 經過多次計算測試,我覺得應該是 [quote:25fcfbfbfb] [b:25fcfbfbfb][size=18:25fcfbfbfb]MaxClients <= ServerLimit * ThreadsPerChild[/size:25fcfbfbfb][/b:25fcfbfbfb][/quote:25fcfbfbfb] |