我想编辑我的httpd.conf来接受最多1000个客户端连接。 这是我现在所拥有的:
StartServers 8 MinSpareServers 5 MaxSpareServers 20 ServerLimit 256 MaxClients 256 MaxRequestsPerChild 4000 StartServers 2 MaxClients 150 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0
我应该如何编辑它?
假设您有足够的RAM来处理请求,并且您正在使用prefork多处理模块,则可以使用2个指令MaxClients和ServerLimit来设置将要服务的同时请求的总数;
检查prefork运行apachectl -V | grep MPM apachectl -V | grep MPM并查找以下输出;
# apachectl -V | grep MPM Server MPM: Prefork -D APACHE_MPM_DIR="server/mpm/prefork"
MaxClients指令设置将被服务的同时请求数量的限制。
通过MaxClients限制的任何连接尝试通常都会排队,直到基于ListenBacklog指令的数字。 一旦subprocess在不同的请求结束时被释放,连接将被服务。
但是, ServerLimit也对apache产生的处理请求数量提出了最大的限制。
对于prefork MPM,ServerLimit指令为Apache进程的生命周期设置MaxClients的最大configuration值。
所以我会去做类似的事情;
ServerLimit 1000 MaxClients 1000
或者, For the worker MPM, this directive in combination with ThreadLimit sets the maximum configured value for MaxClients for the lifetime of the Apache process. Any attempts to change this directive during a restart will be ignored For the worker MPM, this directive in combination with ThreadLimit sets the maximum configured value for MaxClients for the lifetime of the Apache process. Any attempts to change this directive during a restart will be ignored ThreadLimit的工作人员在这里