你如何增加在Apache的并发连接的最大数量? [英] How do you increase the max number of concurrent connections in Apache?
问题描述
什么的httpd的conf设置,我需要改变,以提高Apache的并发连接的最大数量?注意:我关掉的KeepAlive,因为这是一个主要API服务器
#
#的KeepAlive:是否允许永久连接(超过
#每个连接一个请求)。设置为Off则停用。
#
关闭的KeepAlive#
#MaxKeepAliveRequests:请求允许的最大数量
在持久连接期间#。设置为0,允许无限量。
#我们推荐你离开这个数字高,以获得最佳性能。
#
MaxKeepAliveRequests 100#
#的KeepAliveTimeout:的秒数等待来自下一个请求
#在同一连接上相同的客户端。
#
15的KeepAliveTimeout##
##服务器池大小条例(MPM专用)
###prefork MPM
#StartServers的:服务器进程的数目开始
#的MinSpareServers:保有的备用服务器进程的最小数量
#MaxSpareServers的:保有的备用服务器进程的最大数量
#了ServerLimit:用于MaxClients的服务器的寿命最大值
#MaxClients的:服务器进程的最大数量不得开工
#MaxRequestsPerChild:请求的最大数量服务进程
< IfModule prefork.c>
StartServers的8
比MinSpareServers 5
MaxSpareServers的20
将ServerLimit 256
MaxClients的256
MaxRequestsPerChild 4000
< / IfModule>#工人MPM
#StartServers的:服务器进程的初始数量开始
#MaxClients的:客户端同时连接的最大数目
#MinSpareThreads:保有的备用工作线程的最小数量
#MaxSpareThreads:保有的备用工作线程的最大数
#ThreadsPerChild是:在每个服务器进程的工作线程数不变
#MaxRequestsPerChild:请求的最大数量服务进程
< IfModule worker.c中>
StartServers的2
MaxClients的150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild的25
MaxRequestsPerChild 0
< / IfModule>
下面是关于的MaxClients和MaxRequestsPerChild计算的详细解释
<一个href=\"http://www.genericarticles.com/mediawiki/index.php?title=How_to_optimize_apache_web_server_for_maximum_concurrent_connections_or_increase_max_clients_in_apache\">http://www.genericarticles.com/mediawiki/index.php?title=How_to_optimize_apache_web_server_for_maximum_concurrent_connections_or_increase_max_clients_in_apache
16了ServerLimit
StartServers的2
MaxClients的200
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild的25
首先,每当一个apache启动时,它会开始是由 StartServers的
参数确定2子进程。然后,每个进程将开始通过 ThreadsPerChild是
确定的参数,所以这意味着2过程只服务50个并发连接/客户即25x2 = 50 25个线程。现在,如果更多的并发用户来了,然后另一个孩子进程将启动,可另提供服务25个用户。但是,有多少子进程可以启动由将ServerLimit
参数控制,这意味着在上面的配置,我可以有总共16子进程,每个子进程可以处理25线程,在总处理16x25 = 400并发用户。但是,如果在 MaxClients的
定义数目少是200这里,那么这意味着经过8子进程,没有多余的过程将开始,因为我们已经定义<$的上部盖C $ C>的MaxClients 。这也意味着,如果设置了的MaxClients
1000,经过16子进程和400的连接,没有多余的过程将开始,我们不能服务超过400个并发客户即使我们有增加的MaxClient
参数。在这种情况下,我们还需要增加将ServerLimit
来1000年至1025年,即的MaxClients / ThreadsPerChild的= 40
因此,这是optmized配置服务器1000的客户端
&LT; IfModule mpm_worker_module&GT;
将ServerLimit 40
StartServers的2
MaxClients的1000
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild的25
MaxRequestsPerChild 0
&LT; / IfModule&GT;
What httpd conf settings do I need to change to increase the max number of concurrent connections for Apache? NOTE: I turned off KeepAlive since this is mainly an API server.
#
# 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>
Here's a detailed explanation about the calculation of MaxClients and MaxRequestsPerChild
ServerLimit 16
StartServers 2
MaxClients 200
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
First of all, whenever an apache is started, it will start 2 child processes which is determined by StartServers
parameter. Then each process will start 25 threads determined by ThreadsPerChild
parameter so this means 2 process can service only 50 concurrent connections/clients i.e. 25x2=50. Now if more concurrent users comes, then another child process will start, that can service another 25 users. But how many child processes can be started is controlled by ServerLimit
parameter, this means that in the configuration above, I can have 16 child processes in total, with each child process can handle 25 thread, in total handling 16x25=400 concurrent users. But if number defined in MaxClients
is less which is 200 here, then this means that after 8 child processes, no extra process will start since we have defined an upper cap of MaxClients
. This also means that if I set MaxClients
to 1000, after 16 child processes and 400 connections, no extra process will start and we cannot service more than 400 concurrent clients even if we have increase the MaxClient
parameter. In this case, we need to also increase ServerLimit
to 1000/25 i.e. MaxClients/ThreadsPerChild=40
So this is the optmized configuration to server 1000 clients
<IfModule mpm_worker_module>
ServerLimit 40
StartServers 2
MaxClients 1000
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
这篇关于你如何增加在Apache的并发连接的最大数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!