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

之前看资料,有多次看到过说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

发表回复

您的电子邮箱地址不会被公开。