如何從 apache 伺服器日誌中解析「[info] 伺服器似乎很忙」?

如何從 apache 伺服器日誌中解析「[info] 伺服器似乎很忙」?

我已經多次看到這個問題被問過,但沒有任何真正的答案;所以我決定發布我的決議。

info在 apache error.log 中可以看到以下訊息:

[info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 16 children, there are 41 idle, and 129 total children

答案1

解決方案似乎很明顯;增加StartServers直到它消失。雖然確實如此,但任意增加該值是不好的做法,除非您了解其含義並且增加的值實際上會有所幫助。

我正在閱讀 httpd 原始碼,它的內容如下:

/*
 * idle_spawn_rate is the number of children that will be spawned on the
 * next maintenance cycle if there aren't enough idle servers.  It is
 * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
 * without the need to spawn.
 */

此外,在原始程式碼中,在以下情況下會記錄實際錯誤:

if (retained->idle_spawn_rate >= 8) {
                ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, APLOGNO(00162)
                    "server seems busy, (you may need "
                    "to increase StartServers, or Min/MaxSpareServers), "
                    "spawning %d children, there are %d idle, and "
                    "%d total children", retained->idle_spawn_rate,
                    idle_count, total_non_dead);
            }

那麼這意味著什麼;拋出這個錯誤當由於沒有足夠的伺服器來處理請求而在下一個週期產生的子級數量大於 8 時。

那麼如何解決它呢?

每次拋出此錯誤時,您都會看到類似的內容spawning 16 children;這意味著必須產生 16 個子級,因為缺少伺服器來處理請求。基本上,增加StartServers生成子代的數量,直到錯誤消失。您也可以增加Min/MaxSpareServers此數量。

相關內容