在Apache的Access Log中會看到很多如下的訪問日志:
代碼如下:
127.0.0.1 - - [05/May/2011:10:54:07 +0800] "OPTIONS * HTTP/1.0" 200 -
127.0.0.1 - - [05/May/2011:10:54:08 +0800] "OPTIONS * HTTP/1.0" 200 -
127.0.0.1 - - [05/May/2011:10:54:09 +0800] "OPTIONS * HTTP/1.0" 200 -
127.0.0.1 - - [05/May/2011:10:54:10 +0800] "OPTIONS * HTTP/1.0" 200 -
在Apache Prefork模式下, 啟動的時候,Apache就會fork出一些worker進程, 來準備接受請求, 這些worker進程,在完成準備工作以后, 就會進入block模式的監聽沉睡中, 等待請求到來而被喚醒。
另外一方面, 在Prefork模式下, 當請求很多, 目前的worker進程數不夠處理的時候, 就會額外再fork一些worker進程出來, 以滿足當前的請求。
而在這些請求高峰過后, 如果額外fork出來的進程數大于了MaxSpareServers, Apache就會告訴這些worker進程退出, 那么問題就來了。
這些進程都在沉睡中啊, 怎么告訴他們, 并且讓他們自我退出呢?
Apache會首先發送一個退出狀態字(GRACEFUL_CHAR !)給這些Work進程:
代碼如下:static apr_status_t pod_signal_internal(ap_pod_t *pod)
{
apr_status_t rv;
char char_of_death = '!';
apr_size_t one = 1;
rv = apr_file_write(pod->pod_out, &char_of_death, &one);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf,
"write pipe_of_death");
}
return rv;
}
但此時, Worker進程不會去讀這些狀態字, 因為他們還在沉睡。
這個時候Apache就會發送一個OPTIONS請求給自己, 喚醒這些沉睡的進程:
代碼如下:static apr_status_t dummy_connection(ap_pod_t *pod)
{
//...有省略
/* Create the request string. We include a User-Agent so that
* adminstrators can track down the cause of the odd-looking
* requests in their logs.
*/
srequest = apr_pstrcat(p, "OPTIONS * HTTP/1.0/r/nUser-Agent: ",
新聞熱點
疑難解答