2010-08-02 64 views
80

我需要更改哪些httpd conf設置以增加Apache的最大併發連接數?注:我關閉了KeepAlive,因爲這主要是一個API服務器。如何增加Apache中的最大併發連接數?

# 
# 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> 

回答

6

更改MaxClients指令。它現在是256

+1

下面是文檔:http://httpd.apache.org/docs/ 1.3/mod/core.html#maxclients – NullUserException 2010-08-02 16:05:50

138

下面是關於的MaxClients的計算和MaxRequestsPerChild

http://web.archive.org/web/20160415001028/http://www.genericarticles.com/mediawiki/index.php?title=How_to_optimize_apache_web_server_for_maximum_concurrent_connections_or_increase_max_clients_in_apache

ServerLimit 16 
StartServers 2 
MaxClients 200 
MinSpareThreads 25 
MaxSpareThreads 75 
ThreadsPerChild 25 

首先,每當一個apache啓動時,它會開始2個進程的詳細解釋其由StartServers參數確定。然後每個進程將啓動由參數ThreadsPerChild決定的25個線程,因此這意味着2進程可以僅服務50個併發連接/客戶端,即25x2 = 50。現在,如果有更多的併發用戶來到,那麼另一個子進程將啓動,可以爲另外25個用戶提供服務。但是可以啓動多少個子進程由ServerLimit參數控制,這意味着在上面的配置中,我總共可以有16個子進程,每個子進程可以處理25個線程,總共處理16x25 = 400個併發用戶。但是如果MaxClients中定義的數字少於200,那麼這意味着在8個子進程之後,由於我們已經定義了MaxClients的上限,因此不會啓動額外的進程。這也意味着,如果我將MaxClients設置爲1000,在16個子進程和400個連接之後,即使增加了MaxClient參數,也不會啓動額外的進程,並且我們無法爲超過400個併發客戶端提供服務。在這種情況下,我們還需要增加ServerLimit到二十五分之一千即MaxClients/ThreadsPerChild=40 所以這是optmized配置服務器1000級的客戶

<IfModule mpm_worker_module> 
    ServerLimit   40 
    StartServers   2 
    MaxClients   1000 
    MinSpareThreads  25 
    MaxSpareThreads  75 
    ThreadsPerChild  25 
    MaxRequestsPerChild 0 
</IfModule> 
+17

版本2.3.13後似乎有一些變化。例如,MaxClients現在是MaxRequestWorkers。 – 2014-01-02 16:33:23

+1

請指教:該網站鏈接目前正在惡意軟件(和色情)...它可能被黑客...很煩人,如果你正在尋找一個解決方案在stackoverflow和一個完整的色情網站打開... https:///sitecheck.sucuri.net/results/www.genericarticles.com – yoano 2016-04-19 15:01:31

+1

鏈接似乎不起作用 – 2016-10-26 07:56:41

相關問題