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

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

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

    Http協(xié)議的幾個(gè)概念和web browser優(yōu)化

    作者:tacy lee

    寫本文的目的就是想搞清除http1.1和1.0的具體區(qū)別,看過很多別人寫的關(guān)于他們的概念,可能是沒動(dòng)手去測(cè)試,總是模模糊糊

    Persistent HTTP connections

    我們知道,早先的WEB網(wǎng)站都是由一些文字頁(yè)面組成,一個(gè)頁(yè)面可能就是一個(gè)簡(jiǎn)單的http請(qǐng)求,里面也不會(huì)嵌套css,gif類似的資源文件,所以在1.0標(biāo)準(zhǔn)實(shí)現(xiàn)的時(shí)候沒有去考慮連接的效率(用完就丟棄,【1】),現(xiàn)在的頁(yè)面很多都非常復(fù)雜,在里面嵌套二三十個(gè)資源文件是很正常的事情,創(chuàng)建二三十個(gè)tcp連接去下載這些資源,對(duì)于tcp連接的利用率非常低。

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

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

    http規(guī)范里面對(duì)于持久連接的數(shù)量建議為2(firefox和iexplorer缺省都是采用該值),增加該值會(huì)增加服務(wù)器的壓力(需要?jiǎng)?chuàng)建更多的連接),而且對(duì)于網(wǎng)絡(luò)狀況不好的情況只會(huì)導(dǎo)致更大的阻塞,所以不建議修改該值【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設(shè)置
      network.http.max-persistent-connections-per-server
      * iexplorer的Persistent HTTP connections設(shè)置
      http://support.microsoft.com/?kbid=282402

    Pipelining

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

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


      * 沒有實(shí)現(xiàn)Pipelining的瀏覽器發(fā)送的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


      * 實(shí)現(xiàn)了Pipelining的瀏覽器發(fā)送的packet,可以看到,這個(gè)包里面請(qǐng)求了兩個(gè)資源(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(當(dāng)sender無(wú)法確定傳輸數(shù)據(jù)大小的時(shí)候使用),keep-alive對(duì)于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 閱讀(3173) 評(píng)論(0)  編輯  收藏 所屬分類: 性能相關(guān)

    主站蜘蛛池模板: 亚洲色成人网站WWW永久| 亚洲精品无码日韩国产不卡av| 在线a免费观看最新网站| 亚洲日本VA午夜在线电影| 亚洲成片观看四虎永久| 久久精品免费电影| 亚洲AV无码片一区二区三区 | 久久午夜夜伦鲁鲁片无码免费| 亚洲精品在线播放视频| 国产成人免费网站在线观看| 午夜视频在线免费观看| 亚洲国产欧美国产综合一区| 亚洲AV综合色区无码另类小说| 啦啦啦高清视频在线观看免费| 国产裸体美女永久免费无遮挡| 亚洲国产午夜精品理论片| 亚洲中文字幕丝袜制服一区| 美女裸身网站免费看免费网站| 久久国产乱子伦精品免费午夜 | 最近中文字幕mv手机免费高清| 国产精品极品美女自在线观看免费| 亚洲精品国产福利片| 免费人成年激情视频在线观看| 亚洲第一网站免费视频| 国产精品极品美女自在线观看免费 | 免费a级黄色毛片| 天天影院成人免费观看| 高清永久免费观看| 香港一级毛片免费看| 亚洲一区二区三区高清视频| 亚洲精品午夜无码专区| 免费亚洲视频在线观看| 国产h视频在线观看免费| 久久久久久AV无码免费网站下载 | 永久黄网站色视频免费| 曰批全过程免费视频播放网站| 很黄很污的网站免费| 日韩大片免费观看视频播放| 亚洲精品欧美综合四区| 亚洲中文久久精品无码1| 亚洲男人的天堂在线播放|