<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Http協議的幾個概念和web browser優化

    作者:tacy lee

    寫本文的目的就是想搞清除http1.1和1.0的具體區別,看過很多別人寫的關于他們的概念,可能是沒動手去測試,總是模模糊糊

    Persistent HTTP connections

    我們知道,早先的WEB網站都是由一些文字頁面組成,一個頁面可能就是一個簡單的http請求,里面也不會嵌套css,gif類似的資源文件,所以在1.0標準實現的時候沒有去考慮連接的效率(用完就丟棄,【1】),現在的頁面很多都非常復雜,在里面嵌套二三十個資源文件是很正常的事情,創建二三十個tcp連接去下載這些資源,對于tcp連接的利用率非常低。

    另外一方面,tcp連接打開之后,首先采用slow start算法【2】,開始先傳輸幾個小的packet探測網絡情況來確定傳輸速率,而且頁面上嵌入的資源文件往往都比較小,也就是說如果采用http 1.0,就意味著很多的資源傳輸都是在slow start下完成的,效率也很低。

    Persistent HTTP connections就是讓連接重復利用,不需要為每個資源文件都建立一個tcp連接。也不存在slow start問題。

    http規范里面對于持久連接的數量建議為2(firefox和iexplorer缺省都是采用該值),增加該值會增加服務器的壓力(需要創建更多的連接),而且對于網絡狀況不好的情況只會導致更大的阻塞,所以不建議修改該值【3】
      Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy. A proxy SHOULD use up to 2*N connections to another server or proxy, where N is the number of simultaneously active users. These guidelines are intended to improve HTTP response times and avoid congestion

      * firefox 的Persistent HTTP connections設置
      network.http.max-persistent-connections-per-server
      * iexplorer的Persistent HTTP connections設置
      http://support.microsoft.com/?kbid=282402

    Pipelining

    在HTTP 1.0的時候,客戶端的請求都是等到前一個請求完成之后,再發送另一個請求,一個packet里面只能請求一個資源。Pipelining可以讓你在一個packet里面請求多個資源,減少了packet的數量,具體請參考下面示例。

      * firefox Pipelining設置
      network.http.pipelining             (缺省為false,推薦打開)
      network.http.pipelining.maxrequests  (缺省為4,最大為8,建議設置為8)
      * iexplorer設置
      ie沒有實現pipelining


      * 沒有實現Pipelining的瀏覽器發送的packet
    No.     Time        Source                Destination           Protocol Info
         
    52 0.576526    192.168.1.61          203.81.29.137         HTTP     GET /images/index_03.gif HTTP/1.1

    Frame 
    52 (620 bytes on wire, 620 bytes captured)
    Ethernet II, Src: QuantaCo_c3:
    16:11 (00:16:36:c3:16:11), Dst: Intel_5f:99:3a (00:0e:0c:5f:99:3a)
    Internet Protocol, Src: 
    192.168.1.61 (192.168.1.61), Dst: 203.81.XXX.XXX (203.81.XXX.XXX)
    Transmission Control Protocol, Src Port: 
    2320 (2320), Dst Port: http (80), Seq: 1122, Ack: 8456, Len: 566
    Hypertext Transfer Protocol
        GET 
    /images/index_03.gif HTTP/1.1\r\n
        Host: www.primeton.com\r\n
        User
    -Agent: Mozilla/5.0 (Windows;U;Windows NT 5.1; en-US; rv:1.8.1.6)Gecko/20070725 Firefox/2.0.0.6\r\n
        Accept: image
    /png,*/*;q=0.5\r\n
        Accept-Language: en-us,en;q=0.5\r\n
        Accept-Encoding: gzip,deflate\r\n
        Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n
        Keep-Alive: 300\r\n
        Connection: keep-alive\r\n
        Referer: 
    http://www.primeton.com/\r\n
        Cookie: __utmz=33497343.1189057682.16.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); __utma=3349734
    3.241348620.1172460177.1189057682.1189130143.17; __utmb=33497343; __utmc=33497343\r\n
        \r\n


      * 實現了Pipelining的瀏覽器發送的packet,可以看到,這個包里面請求了兩個資源(index_03.gif和SH.jpg)
    No.     Time        Source                Destination           Protocol Info
         
    39 0.558943    192.168.1.61          203.81.29.137         HTTP     GET /images/index_03.gif HTTP/1.1

    Frame 
    39 (1514 bytes on wire, 1514 bytes captured)
    Ethernet II, Src: QuantaCo_c3:
    16:11 (00:16:36:c3:16:11), Dst: Intel_5f:99:3a (00:0e:0c:5f:99:3a)
    Internet Protocol, Src: 
    192.168.1.61 (192.168.1.61), Dst: 203.81.XXX.XXX (203.81.XXX.XXX)
    Transmission Control Protocol, Src Port: 
    2309 (2309), Dst Port: http (80), Seq: 1158, Ack: 24226, Len: 1460
    Hypertext Transfer Protocol
        GET 
    /images/index_03.gif HTTP/1.1\r\n
        Host: www.primeton.com\r\n
        User
    -Agent: Mozilla/5.0 (Windows;U;Windows NT 5.1; en-US; rv:1.8.1.6)Gecko/20070725 Firefox/2.0.0.6\r\n
        Accept: image
    /png,*/*;q=0.5\r\n
        Accept-Language: en-us,en;q=0.5\r\n
        Accept-Encoding: gzip,deflate\r\n
        Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n
        Keep-Alive: 300\r\n
        Connection: keep-alive\r\n
        Referer: 
    http://www.primeton.com/\r\n
        Cookie: __utmz=33497343.1189057682.16.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); __utma=3349734
    3.241348620.1172460177.1189057682.1189130143.17; __utmb=33497343; __utmc=33497343\r\n
        \r\n
    Hypertext Transfer Protocol
        GET /images/SH.jpg HTTP/1.1\r\n
        Host: www.primeton.com\r\n
        User-Agent: Mozilla/5.0 (Windows;U;Windows NT 5.1; en-US; rv:1.8.1.6)Gecko/20070725 Firefox/2.0.0.6\r\n
        Accept: image/png,
    */*;q=0.5\r\n
        Accept
    -Language: en-us,en;q=0.5\r\n
        Accept
    -Encoding: gzip,deflate\r\n
        Accept
    -Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n
        Keep
    -Alive: 300\r\n
        Connection: keep
    -alive\r\n
        Referer: http:
    //www.primeton.com/\r\n
        Cookie: __utmz=33497343.1189057682.16.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); __utma=334973
    43.241348620
    .1172460177.1189057682.1189130143.17; __utmb=33497343; __utmc=33497343\r\n
        \r\n

    chunked

    http/1.0不支持chunked packet(當sender無法確定傳輸數據大小的時候使用),keep-alive對于http/1.0同樣有效,但是不支持chuncked packet

    ====== 參考資料: ======

      * 【1】:Nielsen, H.F., Gettys, J., Baird-Smith, A., Prud'hommeaux, E., Lie, H., and C. Lilley. [[http://www.w3.org/Protocols/HTTP/Performance/Pipeline.html|Network Performance Effects of HTTP/1.1, CSS1, and PNG]], Proceedings of ACM SIGCOMM '97, Cannes France, September 1997.[jg642]
      * 【2】:Spero, S., [[http://www.w3.org/Protocols/HTTP/1.0/HTTPPerformance.html|Analysis of HTTP Performance Problems]], July 1994.
      * 【3】:[[http://www.w3.org/Protocols/rfc2616|Hypertext Transfer Protocol -- HTTP/1.1]]

    posted on 2007-09-07 17:28 tacy lee 閱讀(3182) 評論(0)  編輯  收藏 所屬分類: 性能相關

    主站蜘蛛池模板: 国产精品亚洲精品观看不卡| 亚洲免费综合色在线视频| 最近中文字幕免费2019| 亚洲人成网网址在线看| 香蕉视频在线观看免费国产婷婷| 免费一区二区无码视频在线播放| 亚洲av福利无码无一区二区| 女人被男人桶得好爽免费视频| 一级毛片成人免费看a| 亚洲精品综合久久中文字幕| 午夜网站免费版在线观看| 成人片黄网站色大片免费观看cn| 亚洲综合亚洲国产尤物| 亚洲&#228;v永久无码精品天堂久久 | 色婷婷综合缴情综免费观看| 亚洲AV日韩精品久久久久久久 | 久久国产免费一区二区三区| 亚洲色大成网站WWW国产| 中文字幕亚洲电影| 日韩国产免费一区二区三区| 羞羞视频免费网站日本| 久久精品国产亚洲AV电影| 四虎免费久久影院| 日韩精品极品视频在线观看免费| 在线观看亚洲专区| 亚洲午夜久久久精品电影院| 中文字幕精品亚洲无线码二区| 最近2019中文字幕免费看最新| 久久精品成人免费看| 无忧传媒视频免费观看入口| ass亚洲**毛茸茸pics| 国产亚洲人成网站观看| 亚洲一久久久久久久久| 亚洲av综合avav中文| 四虎AV永久在线精品免费观看| 最近免费mv在线电影| 中文毛片无遮挡高清免费| 久久亚洲精品无码网站| 亚洲AV无码一区二区三区在线| 亚洲成AV人在线观看天堂无码| 亚洲av无码成人精品区|