2016-04-28 465 views
6

我有一個非常繁忙的服務器:使用W3TotalCache APC的PHP(Wordpress),Apache和Cloudflare的Varnish來處理所有流量。 Ubuntu 14.04.4 LTSAH00161:服務器達到MaxRequestWorkers設置,考慮提高MaxRequestWorkers設置

只有一個網站的平均每天點擊量約爲60k。

我每時每刻都會收到此消息。與暫時的流量高峯無關,我們將時間與Google Analytics進行了比較。

Thu Apr 28 14:14:42.938075 2016] [mpm_prefork:error] [pid 19137] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting 
[Thu Apr 28 15:43:25.594147 2016] [core:notice] [pid 19137] AH00051: child pid 19866 exit signal Segmentation fault (11), possible coredump in /etc/apache2 
[Thu Apr 28 15:43:25.594313 2016] [core:notice] [pid 19137] AH00051: child pid 20386 exit signal Segmentation fault (11), possible coredump in /etc/apache2 
[Thu Apr 28 15:43:25.594407 2016] [core:notice] [pid 19137] AH00051: child pid 19143 exit signal Segmentation fault (11), possible coredump in /etc/apache2 
[Thu Apr 28 15:43:25.594498 2016] [core:notice] [pid 19137] AH00051: child pid 19144 exit signal Segmentation fault (11), possible coredump in /etc/apache2 
[Thu Apr 28 15:43:25.594572 2016] [core:notice] [pid 19137] AH00051: child pid 20597 exit signal Segmentation fault (11), possible coredump in /etc/apache2 
[Thu Apr 28 15:43:25.594642 2016] [core:notice] [pid 19137] AH00051: child pid 20395 exit signal Segmentation fault (11), possible coredump in /etc/apache2 
[Thu Apr 28 15:43:25.594704 2016] [core:notice] [pid 19137] AH00051: child pid 20424 exit signal Segmentation fault (11), possible coredump in /etc/apache2 
[Thu Apr 28 15:43:25.594785 2016] [core:notice] [pid 19137] AH00051: child pid 20598 exit signal Segmentation fault (11), possible coredump in /etc/apache2 
[Thu Apr 28 15:43:25.594870 2016] [core:notice] [pid 19137] AH00051: child pid 19861 exit signal Segmentation fault (11), possible coredump in /etc/apache2 
[Thu Apr 28 15:43:25.594957 2016] [core:notice] [pid 19137] AH00051: child pid 19782 exit signal Segmentation fault (11), possible coredump in /etc/apache2 
.... 
.... 

所以我增加MaxRequestWorkers第一個100,然後500,目前其在1024但還是發生了。

這是我目前的apache2.conf。 代碼:

<IfModule mpm_worker_module> 
StartServers 256 
MinSpareThreads 256 
MaxSpareThreads 256 
MaxClients 256 
ServerLimit 256 
ThreadLimit 256 
ThreadsPerChild 256 
MaxRequestWorkers 1024 
MaxConnectionsPerChild 0 
MaxRequestPerChild 1000 
</IfModule> 

有很多免費的RAM和負荷平均在0.5左右,有時超過1,但從來沒有見過它高於2.因此,服務器似乎健康的處理流量。

top - 16:07:47 up 3 days, 18:18, 2 users, load average: 0.57, 0.46, 0.55 
Tasks: 113 total, 1 running, 112 sleeping, 0 stopped, 0 zombie 
%Cpu(s): 10.5 us, 2.0 sy, 0.0 ni, 87.4 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st 
KiB Mem: 8176816 total, 2372560 used, 5804256 free, 189684 buffers 
KiB Swap:  0 total,  0 used,  0 free. 1286692 cached Mem 

    PID USER  PR NI VIRT RES SHR S %CPU %MEM  TIME+ COMMAND                                    
21930 www-data 20 0 337212 83308 60072 S 24.9 1.0 0:52.89 apache2                                    
21945 www-data 20 0 327640 72684 58816 S 24.3 0.9 0:48.37 apache2                                    
1182 nobody 20 0 702868 442268 83496 S 0.7 5.4 42:41.32 varnishd 

任何想法爲什麼Apache中斷?

∥焦

+0

我增加MaxRequestWorkers 5000,服務器現在已經超過24小時穩定。最近幾周最長的時間,而不必重新啓動Apache。 –

+0

流量已經增加到每天約200萬次點擊,我們也遇到同樣的問題。 StartServers的1024 MinSpareThreads 1024 MaxSpareThreads 1024 的MaxClients 1024 了ServerLimit 1024 將ThreadLimit 1024 ThreadsPerChild是1024個 MaxRequestWorkers 8192 MaxConnectionsPerChild 0 MaxRequestPerChild 4096 有什麼你可以做更多,而不增加更多服務器? –

+0

Stack Overflow是編程和開發問題的網站。這個問題似乎與題目無關,因爲它不涉及編程或開發。請參閱幫助中心的[我可以詢問哪些主題](http://stackoverflow.com/help/on-topic)。也許[超級用戶](http://superuser.com/)或[Unix&Linux堆棧交換](http://unix.stackexchange.com/)會是一個更好的地方。另請參閱[我在哪裏發佈關於Dev Ops的問題?](http://meta.stackexchange.com/q/134306) – jww

回答

6

基本上配置得到了overritten在: /etc/apache2/mods-available/mpm_prefork.conf

我把新的設置在該文件中,似乎阿帕奇現在工作是正確的。

希望這可以幫助別人,不要把你的配置直接放在apache2.conf或httpd.conf中。確保你改變了所有加載的配置文件。

+6

我很高興它似乎爲您解決,但當您說「我把新在那個文件中設置「,你指的是哪一個設置?舊價值是什麼,新價值是什麼? – Danny

+3

Downvoting:此回覆對其他人沒有用處 - 您不包括您實際做出的更改或給出有關此問題的其他人可以解決該問題的指示。請更新有用的信息/您替換的配置/鍵值對的片段/等。 –

+0

@MattRabe Downvoting爲了什麼?除非您不熟悉Apache或Linux目錄/文件,否則所提供的答案完全可以理解。 –

0

您可能想檢查您的網絡服務器訪問日誌。如果日誌充斥着xml-rpc帖子(例如「POST /xmlrpc.php HTTP/1.1」200 403),您可能會成爲xml-rpc攻擊的目標。有很多方法可以防止它發生,但Wordpress很容易出現這種情況。

1

您修改了錯誤的文件。你的日誌說「mpm_prefork」錯誤。所以你需要修改mpm_prefork.conf而不是mpm_worker.conf。

您也可以使用「apachectl -M」來查看您正在使用的模塊。 例如我的Apache2使用mpm_event_module,所以我需要修改mpm_event.conf

$ apache2ctl -M 
Loaded Modules: 
core_module (static) 
so_module (static) 
watchdog_module (static) 
http_module (static) 
log_config_module (static) 
logio_module (static) 
version_module (static) 
unixd_module (static) 
access_compat_module (shared) 
alias_module (shared) 
auth_basic_module (shared) 
authn_core_module (shared) 
authn_file_module (shared) 
authz_core_module (shared) 
authz_host_module (shared) 
authz_user_module (shared) 
autoindex_module (shared) 
deflate_module (shared) 
dir_module (shared) 
env_module (shared) 
filter_module (shared) 
mime_module (shared) 
**mpm_event_module (shared)** 
negotiation_module (shared) 
setenvif_module (shared) 
status_module (shared) 
wsgi_module (shared) 
1

,你應該修改mpm_prefork

<IfModule mpm_prefork_module> StartServers 10 MinSpareServers 10 MaxSpareServers 20 ServerLimit 2000 MaxRequestWorkers 1500 MaxConnectionsPerChild 10000 </IfModule>