浏览器访问服务器的速度问题分析

之前看资料,有多次看到过说ie浏览器的客户端在与一个服务器之间(特指http 服务)最多建立2个TCP连接来传输http request。F5可以利用express connect通过增加域名的方式来增加连接数。
我观察过多次,访问我的网站 总能看到10个连接
TCP    192.168.0.185:3632     125.76.229.121:80      ESTABLISHED
TCP    192.168.0.185:3633     125.76.229.121:80      ESTABLISHED
TCP    192.168.0.185:3634     125.76.229.121:80      ESTABLISHED
TCP    192.168.0.185:3635     125.76.229.121:80      ESTABLISHED
TCP    192.168.0.185:3636     125.76.229.121:80      ESTABLISHED
TCP    192.168.0.185:3637     125.76.229.121:80      ESTABLISHED
TCP    192.168.0.185:3638     203.171.232.42:80      ESTABLISHED
TCP    192.168.0.185:3639     125.76.229.121:80      ESTABLISHED
TCP    192.168.0.185:3640     125.76.229.121:80      ESTABLISHED
TCP    192.168.0.185:3641     125.76.229.121:80      ESTABLISHED
TCP    192.168.0.185:3642     125.76.229.121:80      ESTABLISHED

这就让我迷惑。今天在网上一番google,终于明白了点:
原来根据RF2616的要求,客户端和同一个server之间确实只能建立不超过2个TCP(http 1.1是2个,1.0是4个连接)连接以避免拥塞
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.

但是这个不是绝对的,不同的浏览器行为可能并不一样。对于IE有这样一个注册表设置:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings

MaxConnectionsPerServer REG_DWORD (Default 2)
Sets the number of simultaneous requests to a single HTTP 1.1 Server

MaxConnectionsPer1_0Server REG_DWORD (Default 4)
Sets the number of simultaneous requests to a single HTTP 1.0 Server

这是标准的,但是我的电脑是IE7,他们的值都是10,我想在IE8应该也是这样吧
我查了微软的文档,http://support.microsoft.com/kb/183110/en-us,6.0(含)以前的版本应该都是2. 大家可以验证下。

我将限制值改为2后,再查看发现确实只能同时建立2个TCP连接了。
  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:443            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:2869           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:15000          0.0.0.0:0              LISTENING
  TCP    127.0.0.1:1045         0.0.0.0:0              LISTENING
  TCP    127.0.0.1:1100         0.0.0.0:0              LISTENING
  TCP    127.0.0.1:62514        0.0.0.0:0              LISTENING
  TCP    192.168.0.185:139      0.0.0.0:0              LISTENING
  TCP    192.168.0.185:1071     219.133.60.243:8000    CLOSE_WAIT
  TCP    192.168.0.185:2307     121.0.19.146:16000     ESTABLISHED
  TCP    192.168.0.185:3609     60.28.183.195:80       TIME_WAIT
  TCP    192.168.0.185:3615     60.28.183.195:80       TIME_WAIT
  TCP    192.168.0.185:3618     125.76.229.121:80      ESTABLISHED
  TCP    192.168.0.185:3619     125.76.229.121:80      ESTABLISHED
  TCP    192.168.0.185:3620     203.171.232.42:80      ESTABLISHED
  TCP    192.168.0.185:3621     125.46.105.130:80      ESTABLISHED
  TCP    192.168.0.185:3623     60.12.231.25:80        ESTABLISHED
  TCP    192.168.0.185:3624     60.12.231.15:80        ESTABLISHED
  TCP    192.168.0.185:3625     61.189.20.200:80       SYN_SENT
  TCP    192.168.0.185:4952     207.46.107.64:1863     ESTABLISHED
  TCP    192.168.0.185:4989     207.46.26.130:1863     ESTABLISHED
  TCP    192.168.0.185:4990     64.4.36.22:1863        ESTABLISHED
  TCP    192.168.0.185:4991     207.46.26.76:1863      ESTABLISHED
  TCP    192.168.0.185:4992     65.54.171.33:1863      ESTABLISHED
  TCP    192.168.0.185:4993     65.54.171.39:1863      ESTABLISHED
  TCP    192.168.0.185:4995     207.46.26.153:1863     ESTABLISHED
  TCP    192.168.124.1:139      0.0.0.0:0              LISTENING
  TCP    192.168.194.1:139      0.0.0.0:0              LISTENING

关于鸡鸡哥的聪明伶俐的儿子和如花似玉的老婆

嗜抽烟,嗜吃肉,常睡觉晚起,熬夜,看新闻,喜体育栏目,会操作电脑,会操作服务器,能做些别人不屑于做的事情。厌做饭,恶洗碗,不洗澡,不刷牙,不剃胡须,不喜逛超市,重压之下偶去之,无上进心,无恒心,无毅力。 1988-1998年,虚度人生 2001-2013年,懵懵懂懂忽然就有孩子有老婆有,匆匆间父亲去世,匆匆半个人生没有了 2013- 知道自己需要什么,知道自己该做什么,知道自己的是个什么样的人,重新上路,明明白白活自己。 ------鸡鸡哥 2013.02.28 老了,以后得改称老鸡鸡哥了,继续努力吧 -----鸡鸡哥 20150517
此条目发表在web网站优化分类目录。将固定链接加入收藏夹。

发表评论