In the past two days, I have built a set of Apache servers. Each server has 4G of memory and uses prefork mode. The number of connections set at the beginning was too few and it took a long time to respond to user requests. Later, I modified Apache 2.0. 59 configuration file httpd.conf:
Quote
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
StartServers 10
MinSpareServers 10
MaxSpareServers 15
ServerLimit 2000
MaxClients 2000
MaxRequestsPerChild 10000
Check the number of httpd processes (that is, the number of concurrent requests that Apache can handle in prefork mode):
Linux command:
Quote
ps -ef | grep httpd | wc -l
Return result example:
1388
Indicates that Apache can handle 1388 concurrent requests. This value can be automatically adjusted by Apache according to the load. The peak value of each server in my group has reached 2002.
Check the number of concurrent requests of Apache and its TCP connection status:
Linux command:
Quote
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
(This statement comes from I got it from Mr. Wang, Technical Director of Sina Interactive Community Business Department, which is very good)
Return result example:
LAST_ACK 5
SYN_RECV 30
ESTABLISHED 1597
FIN_WAIT1 51
FIN_WAIT2 504
TIME_WAIT 1057
SYN_RECV indicates the number of requests that are waiting to be processed; ESTABLISHED indicates the normal data transmission status; TIME_WAIT indicates the number of requests that have been processed and are waiting for the timeout to end.
Regarding the changes in TCP status, it can be seen vividly from the following figure:
STATUS: DESCRIPTION CLOSED: No connection is active or in progress LISTEN: The server is waiting for incoming calls SYN_RECV: A connection request has arrived, waiting for confirmation SYN_SENT: The application has started, opening a connection ESTABLISHED: Normal data transfer status FIN_WAIT1: The application says it Completed FIN_WAIT2: The other side has agreed to release ITMED_WAIT: Wait for all packets to die CLOSING: Both sides try to close at the same time TIME_WAIT: The other side has initialized a release LAST_ACK: Wait for all packets to die