the maximum number of connections to Apache, by default, is 256. Modify the maximum number of Apache connections by: First, modify./apache/conf/httpd.conf file. # VI httpd.conf will be "#Include conf/extra/httpd-mpm.conf "Before the # is removed. Save. Two: Revise again./apache/conf/extra/httpd-mpm.conf file. # VI httpd-mpm.conf found<ifmodule mpm_prefork_module>the original line:<ifmodule mpm_prefork_module>startservers5minspareservers5maxspareserversTenmaxclients MaxMaxrequestsperchild0</IfModule>after modification<ifmodule mpm_prefork_module>startservers5minspareservers5maxspareserversTenServerlimit themaxclients +Maxrequestsperchild0Note:1, must add Serverlimit, and in front of the maxclients, and the value is larger than maxclient;2, restart Apache, just/bin/apachectl Restart Invalid, need to Apachectl stop and then apachectl start to Apache concurrency control parameters prefork Understanding and tuning an Apache with Linux under the concurrency is not very High, about 3K, the normal server will be different degrees of problems. Apache about concurrency control is mainly prefork and worker two one of them to control. We can use httpd-l to determine if the MPM currently in use is PREFORK.C or WORKER.C. The following is the configuration for prefork in Apache. The following are the optimized parameters.<ifmodule prefork.c>#有这个参数就不必像apache1一样修改源码才能修改256客户数的限制, listen to the front to be put into effect, 2000 is the maximum value of this parameter Serverlimit -#指定服务器启动时建立的子进程数量, Prefork defaults to 5. Startservers -#指定空闲子进程的最小数量, the default is 5. If the number of currently idle child processes is less than minspareservers, then Apache will produce a new subprocess at a maximum speed of one second. Do not set this parameter too large. Minspareservers -#设置空闲子进程的最大数量, the default is 10. If there are currently more than maxspareservers of idle child processes, the parent process kills the extra child processes. Do not set this parameter too large. If you set the value of this directive to be smaller than Minspareservers, Apache will automatically modify it to"minspareservers+1". Maxspareservers -#限定同一时间客户端最大接入请求的数量 (number of concurrent threads per process), default is 256. Any request exceeding the maxclients limit will enter the waiting queue, and once a link is freed, the request in the queue will be serviced. To increase this value, you must increase the serverlimit at the same time. MaxClients -#每个子进程在其生存期内允许伺服的最大请求数量, the default is 10000. When the Maxrequestsperchild limit is reached, the child process will end. If the Maxrequestsperchild is"0", the child process will never end. Maxrequestsperchild10000</IfModule>setting Maxrequestsperchild to a value other than 0 has two benefits:1. You can prevent (accidental) memory leaks from running indefinitely, thus exhausting memory. 2give the process a limited lifespan, which helps reduce the number of active processes when the server load is reduced. How it works: a separate control process (the parent process) is responsible for generating child processes that are used to listen for requests and respond. Apache always tries to keep some spare (spare) or idle child processes in the process of meeting incoming requests. This way, the client does not need to wait for the child process to be generated before the service is received. In Unix systems, the parent process typically runs as root for 80 ports, and Apache-generated child processes are typically run with a low-privileged user. The user and group directives are used to set up low-privileged users of child processes. The user who runs the child process must have read permission to the content it serves, but must have as few permissions as possible for other resources than the service content. We tune often to see the number of httpd processes (that is, the number of concurrent requests that Apache can handle in prefork mode): #ps-ef | grep httpd | WC-The result of this is the number of concurrent requests that Apache can handle, which is automatically tuned according to the load. View the number of concurrent requests for Apache and its TCP connection status: Status: Description closed: No connection is active or in progress listen: The server is waiting to enter the call SYN_RECV: A connection request has arrived, wait for confirmation Syn_sent: application has started, open a connection established: Normal data transfer status fin _WAIT1: The app says it's done Fin_wait2: the other side has agreed to release itmed_wait: Wait for all the packets to die closing: Both sides simultaneously try to close the time_wait: the other side has initialized a release processing complete, wait timeout end Last_ ACK: Wait for all packets to die
Modify the maximum number of Apache connections