View the number of httpd processes (that is, the number of concurrent requests that Apache can process in prefork mode): Linux Command: ps-ef | grep httpd | wc-l return result example: 1388 indicates that Apache can process 1388 concurrent requests. This value is automatically adjusted based on the load. The peak value of each server in my group has reached 2002. View the number of concurrent Apache requests and their TCP connection status: Linux Command: www.2cto.com netstat-n | awk '/^ tcp/{++ S [$ NF]} END {for (a in S) print, S [a]} 'return result example: LAST_ACK 5 SYN_RECV 30 ESTABLISHED 1597 FIN_WAIT1 51 FIN_WAIT2 504 TIME_WAIT 1057 where SYN_RECV indicates the number of requests awaiting processing; ESTABLISHED indicates normal data transmission status; TIME_WAIT indicates the number of requests that have been processed and wait for the timeout to end. How can I reasonably set the maximum number of connections for apache httpd? The number of online users of a website increases, and the access time is slow. It is initially considered that the server resources are insufficient, but after repeated tests, Once connected, you can quickly open it by constantly clicking different links on the same page, this phenomenon means that the maximum number of connections in apache is full, and new visitors can only wait in queue for idle connections. If the connection is established, the default value is 5 seconds). You do not need to re-open the connection. Therefore, the solution is to increase the maximum number of connections of apache. 1. Where can I set it? The server is FreeBSD 6.2, apache 2.24, and uses the default configuration (FreeBSD does not load the custom MPM configuration by default). The default maximum number of connections is 250 at/usr/local/etc/apache22/httpd. load the MPM configuration in conf (remove the preceding note): # Server-pool management (MPM specific) include etc/apache22/extra/httpd-mpm.conf visible MPM configuration in/usr/local/etc/apache22/extra/httpd-mpm.conf, but inside according to the httpd working mode divided a lot of blocks, which one is the current httpd working mode? You can run apachectl-l to view: Compiled in modules: www.2cto.com core. c prefork. c http_core.c mod_so.c can see the prefork word. Therefore, the current httpd should work in the prefork mode. The default configuration of the prefork mode is: <IfModule mpm_prefork_module> StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 150 MaxRequestsPerChild 0 </IfModule> 2. how many do I need to add? Theoretically, the larger the number of connections is, the better, but it must be within the capacity range of the server. This is related to the CPU, memory, bandwidth, and so on of the server. To view the number of connections, you can use: ps aux | grep httpd | wc-l or: pgrep httpd | wc-l to calculate the average memory usage of httpd: ps aux | grep-v grep | awk '/httpd/{sum + = $6; n ++}; END {print sum/n}' because basically all pages are static pages, CPU consumption is very low, and the memory occupied by each process is not much, about 200 kb. The server memory is 2 GB, and about 500 mb (conservatively estimated) is required except for services started normally. GB is available, theoretically, 1.5*1024*1024*1024/200000*8053.06368 = www.2cto.com can be supported for about 8 K processes. It is no problem to support concurrent accesses (ensure that 8 K of them can access the website quickly, others may take 1 or 2 seconds to connect, but once connected, it will be smooth) MaxClients that controls the maximum number of connections, so you can try to configure it: <IfModule mpm_prefork_module> StartServers 5 limit 5 MaxSpareServers 10 ServerLimit 5500 MaxClients 5000 MaxRequestsPerChild 100 </IfModule> note that the maximum value of MaxClients is 250 by default. to exceed this value, you must explicitly set ServerLimit. The ServerLimit value must be placed before MaxClients and be smaller than MaxClients. Otherwise, a prompt will be displayed when you restart httpd. After restarting httpd, run pgrep httpd | wc-l repeatedly to check the number of connections. You can see that the number of connections does not increase after the value of MaxClients is reached, but the Website access is smooth at this time, you don't need to be greedy and set a higher value. Otherwise, the server memory will be consumed if the Website access suddenly increases. You can adjust the memory usage according to the future access pressure trend and memory usage changes, until an optimal setting value is found. (MaxRequestsPerChild cannot be set to 0, and the server may crash due to memory leakage.) formula for optimal maximum value calculation: www.2cto.com memory <(total_hardware_memory/memory) * 2apache_max_process = memory * 1.5 attached: number of HTTPD connections detected in real time: watch-n 1-d "pgrep httpd | wc-l" author yangemil