HTTP Keep-Alive
Keep-Alive功能使客戶端到服務器端的連接持續有效,當出現對服務器的後繼請求時,Keep-Alive功能避免了建立或者重新建立連接。市場上 的大部分Web服務器,包括iPlanet、IIS和Apache,都支持HTTP Keep-Alive。對於提供靜態內容的網站來說,這個功能通常很有用。但是,對於負擔較重的網站來說,這裏存在另外一個問題:雖然爲客戶保留打開的連 接有一定的好處,但它同樣影響了性能,因爲在處理暫停期間,本來可以釋放的資源仍舊被佔用。當Web服務器和應用服務器在同一臺機器上運行時,Keep- Alive功能對資源利用的影響尤其突出。 此功能爲HTTP 1.1預設的功能,HTTP 1.0加上Keep-Alive header也可以提供HTTP的持續作用功能。
Keep-Alive: timeout=5, max=100
timeout:過期時間5秒(對應httpd.conf裏的參數是:KeepAliveTimeout),max是最多一百次請求,強制斷掉連接
就是在timeout時間內又有新的連接過來,同時max會自動減1,直到爲0,強制斷掉。見下面的四個圖,注意看Date的值(前後時間差都是在5秒之內)!
Tomcat中的相關設置,在server.xml 中的Connector 元素中。
keepAliveTimeout:
The number of milliseconds this Connector will wait for another HTTP request before closing the connection. The default value is to use the value that has been set for the connectionTimeout attribute.
maxKeepAliveRequests:
The maximum number of HTTP requests which can be pipelined until the connection is closed by the server. Setting this attribute to 1 will disable HTTP/1.0 keep-alive, as well as HTTP/1.1 keep-alive and pipelining. Setting this to -1 will allow an unlimited amount of pipelined or keep-alive HTTP requests. If not specified, this attribute is set to 100.
keepalive
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Linux基本操作命令
wbzjacky
2019-02-24 13:12:38
真實的模擬***綜合實驗
wbzjacky
2019-02-24 13:12:37
三層交換機的HSRP、vlan、端口聚合
wbzjacky
2019-02-24 13:12:37
HSRP和二層交換機的端口聚合、vlan
wbzjacky
2019-02-24 13:12:37
如果同事暗中傷害你,應該怎麼辦?
這個饅頭有餡
2019-02-24 13:59:08
職場中,抱怨越多的員工,越被領導瞧不起!
這個饅頭有餡
2019-02-24 13:59:08
老程序員被裁,應屆生卻能月薪 1.3 萬?這你能忍?
前端高達
2019-02-24 13:48:04
遇到到處蹭吃卻從不請客吃飯的主怎麼辦?
樑軍年
2019-02-24 13:26:35
高標準機房綜合配線安裝
wbzjacky
2019-02-24 13:12:38
IPsec ***實驗
wbzjacky
2019-02-24 13:12:37
CISCO路由AAA的Easy ***
wbzjacky
2019-02-24 13:12:37
CISCO訪問控制列表 企業網絡管理的必殺技
wbzjacky
2019-02-24 13:12:37