Total Pageviews

Saturday, 11 November 2017

Apache 2.2之internal dummy connection問題

Apache 架好,網站的資料也都弄好,最後。自然是要來看看 log 檔。看看有沒有錯誤訊息,還是啥異常現象!
結果,一看,還真的有耶!
localhost - - [09/Nov/2008:08:16:36 +0800] "GET / HTTP/1.0" 200 16267 "-" "Apache (internal dummy connection)"
這是啥碗公呀?
照例,自然是要問一下 Google。
Apache 官方的說明如下:
"When Apache HTTP Server manages its child processes, it needs a way to wake up processes that are listening for new connections. To do this, it sends a simple HTTP request back to itself... These requests are perfectly normal and you do not, in general, need to worry about them. They can simply be ignored.

說真的,看起來實在覺得它有一些礙眼。除了礙眼,也有人回報使用動態網頁的網站, CPU 的 loading 有受到影響。

解決的方式分三個部份:
1. 減少它發生的機會(修改 /etc/apache2/apach2.conf),找到 IfModule mpm_worker_module 這一段:
StartServers 15
MinSpareServers 5
MaxSpareServers 20
MaxClients 150
MaxRequestsPerChild 0
增加 MaxSpareServers 的數量(請依您 server 的連線狀況來做調整),這個可以減少它發生的機率。(不過,以上的說法,我沒有證實,所以,我也不確定是否真的有效。)

2. 減少發生還是會發生,所以把這 Request 導到一個固定的網頁:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule ^/$ /blank.html [L]
3. 不要把這資訊寫到 log 裡:
SetEnvIf Remote_Addr "::1" dontlog
CustomLog /var/log/httpd/access.log combined env=!dontlog

這是我目前參考了一些資料所找出的治標的方式,希望很快會有治本的方式!


No comments:

Post a Comment