浏览器并发连接数(转载)

来源:互联网 发布:中国电影票房数据分析 编辑:程序博客网 时间:2024/05/22 20:53
 这是个老话题了,先总结一下HTTP1.1下主流浏览器在单个主机下的并发连接数:

IE6                                      2
IE7                                      2
IE8                                      6
Firefox2                               2
Firefox3                               6
Safari 3,4                      4     
Chrome 1,2                    6     
Opera 9.63,10.00alpha     4 


看上去巧合的是:老版本的IE和Firefox都使用较低的单个主机并发连接数(2),而新版本的IE和Firefox都使用较高的单个主机并发连接数(6)。说起来老版本的IE和Firefox之所以采用较低的单个主机并发连接数是有道理的,在RFC2616里明确要求了单个主机并发连接数的数目:

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和Firefox才会不约而同的采用较高的单个主机并发连接数。

不过很多时候我们为了效率还想得到更高的并发连接数,比如说我们总会看到一些大网站采用独立域名或者二级域名来设置专门的图片服务器,其实有一部分原因就 是为了增加并发连接数。至于使用独立域名还是二级域名的差别在于Cookie的影响,当使用和主站根域名相同的二级域名时,请求的同时也会捎带着传递主站 根域名的Cookie,而使用和主站根域名不同的独立域名时,则不会受主站根域名Cookie的影响,所以带宽占用会更小一些。

不过也不是说并发连接数越大越好,假如新版浏览器得到普及,即使你的网站的平均流量还维持在和以前一样的水平,那么峰值流量也会成倍增加。

顺便说说Firefox下怎么调整单个主机下的并发数:

# about:config
network.http.max-connections                      : 30
network.http.max-connections-per-server           : 15
network.http.max-persistent-connections-per-proxy : 8
network.http.max-persistent-connections-per-server: 6


需要说明的是HTTP1.1下以network.http.max-persistent-connections-per-server的指为准,这是 因为HTTP1.1下缺省都是持久连接,反之如果是HTTP1.0,则以network.http.max-connections-per- server为准。

如果你使用TamperData检测一下,就能发现:

HTTP1.1下Connection: Keep-Alive
HTTP1.0下Connection: Close

一个测试并发速度的页面:

http://stevesouders.com/hpws/parallel-downloads.php

参考链接:Roundup on Parallel Connections

http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-connections/

 

======================================

http://apps.hi.baidu.com/share/detail/31628030

http://www.iefans.net/qingqiu-bingfa-lianjieshu-xianzhi/

原创粉丝点击