我需要更改什么httpd conf设置才能增加Apache的最大并发连接数?注意:我关闭了KeepAlive,因为这主要是一个API服务器.
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive Off
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100
#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 15
##
## Server-Pool Size Regulation (MPM specific)
##
# 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
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
Run Code Online (Sandbox Code Playgroud)
小智 164
以下是有关MaxClients和MaxRequestsPerChild计算的详细说明
ServerLimit 16
StartServers 2
MaxClients 200
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
Run Code Online (Sandbox Code Playgroud)
首先,每当apache启动时,它将启动由StartServers参数确定的2个子进程.然后每个进程将开始通过确定25个线程ThreadsPerChild参数所以这意味着2个过程可以服务只有50并发连接/客户端,即25x2 = 50.现在,如果有更多并发用户,则会启动另一个子进程,可以为另外25个用户提供服务.但是可以启动多少子进程由ServerLimit参数控制,这意味着在上面的配置中,我总共可以有16个子进程,每个子进程可以处理25个线程,总共处理16x25 = 400个并发用户.但是如果定义的数字MaxClients是较小的,这里是200,那么这意味着在8个子进程之后,由于我们已经定义了一个上限,所以不会开始额外的进程MaxClients.这也意味着如果我设置MaxClients为1000,在16个子进程和400个连接之后,将不会启动额外的进程,即使我们增加了MaxClient参数,我们也无法为超过400个并发客户端提供服务.在这种情况下,我们还需要增加到ServerLimit1000/25即MaxClients/ThreadsPerChild=40
所以这是服务器1000客户端的优化配置
<IfModule mpm_worker_module>
ServerLimit 40
StartServers 2
MaxClients 1000
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
Run Code Online (Sandbox Code Playgroud)
更改MaxClients指令.它现在是256.
| 归档时间: |
|
| 查看次数: |
307655 次 |
| 最近记录: |