apache 2.0.48上如何改变默认的MAX CLIENTS

apache 2.0.48上如何改变默认的MAX CLIENTS

我在apache 1.3.17上做成功了,使原来默认的256个MAX CLIENTS改为8192个,但是却在apache2.0.48上不得其法,请教高手赐教了。(在1。3。27上修改了HTTPD.H这个文档,可是在2.0.48上,我晕。)
在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相关的核心参数以获得最大的性能。
无限感激中,原以为我已看懂了APACHE 2.0.48的说明文档,而且检查语法时,也出面ServerLimi  我竟没有耐心去找到它。唉。谢谢大哥!!!

BTW:按你的提示,我已搞定,解决了困惑很久的问题。
http://xcdx.enhand.net/viewthread.php?tid=3260
谢过,只是我也有找到相关的网址呢,不错的说,让我对此有了更深的认识,而且我已成功的做成了。

想说,大家有时间的话,有些联系方式可以吗,组成共同的爱好者,为了我们的工作和爱好,努力一回吧!
有时想找几个志同道合者,可是,却没有人回应啊。QQ45723305
其实用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看的也很糙,希望和大家讨论。
根据这位仁兄的说法,我做了两台服务器,一个是PREFORK的模式,一个是WORKER的工作模式,用MRTG做的流量监控,可能防问用户数量的问题,不是太明显,不过也感受了新的变化,谢过,请多交流吧?


QUOTE:
原帖由 "peng" 发表:
其实用apache2的话,./configure中应该用--with-mpm=worker参数,这样才能发挥apache2的多线程机制。
vi ~apache_install_path/conf/httpd.conf

IfModule worker.c>;
StartServers         2
MaxClients    ..........



QUOTE:
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.

http://httpd.apache.org/docs-2.0/misc/perf-tuning.html#compiletime

  


QUOTE:
原帖由 "peng" 发表:
其实用apache2的话,./configure中应该用--with-mpm=worker参数,这样才能发挥apache2的多线程机制。
vi ~apache_install_path/conf/httpd.conf

IfModule worker.c>;
StartServers         2
MaxClients    ..........

因为在设置的时候出现错误,所以把我的想法说说看。


设置

[Copy to clipboard] [ - ]
CODE:
ServerLimit 8
StartServers 2
MinSpareThreads 15
MaxSpareThreads 25
ThreadsPerChild 25
MaxRequestsPerChild  1000
MaxClients 250

错误:

[Copy to clipboard] [ - ]
CODE:
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.

经过多次计算测试,我觉得应该是

QUOTE:
MaxClients <= ServerLimit * ThreadsPerChild