主流浏览器并发连接数
浏览器默认对同一域下的资源,只保持一定的连接数,会阻塞过多的连接。rfc2616建议不超过2个:
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.
不同浏览器的默认值不一样,对于不同的HTTP协议其值也不一样。见下表。
浏览器 | HTTP 1.1 | HTTP 1.0 |
---|---|---|
IE 6,7 | 2 | 4 |
IE 8 | 6 | 6 |
Firefox 2 | 2 | 8 |
Firefox 3 | 6 | 6 |
Safari 3, 4 | 4 | 4 |
Chrome 1,2 | 6 | ? |
Chrome 3 | 4 | 4 |
Opera 9.63,10.00alpha | 4 | 4 |
上表数据来自Steve Souders。
总的来看,HTTP1.0下允许的连接数普遍大于HTTP1.1协议下的,是因为HTTP1.1是保持连接的,本身对同域下资源的获取就是优化的,且对资源的消耗要大于HTTP1.0。在rfc2616中说到,限制连接数的目的在于提高响应速度和避免拥塞。
修改浏览器最大连接数
1. Firefox
在文件 X:\Program Files\Mozilla Firefox\greprefs\all.js中,有如下的参数:
// a new connection will only be attempted if the number of active persistent
// connections to the server is less then max-persistent-connections-per-serve r.
pref("network.http.max-persistent-connections-per-server", 6);
// if network.http.keep-alive is true, and if connecting via a proxy, then a
// new connection will only be attempted if the number of active persistent
// connections to the proxy is less then max-persistent-connections-per-proxy .
pref("network.http.max-persistent-connections-per-proxy", 8);
2. IE
需要修改注册表或组策略,详情见微软的技术支持。