是有太多的多个同时AJAX连接不好?太多、是有、多个、不好

2023-09-11 01:00:51 作者:______空島空心。

我正在写一个相当大的基于JavaScript的应用程序,有时甚至有些时候它甚至八(8)AJAX请求正在进行一次。这是IE6的​​一个问题,因为它杀死的请求的其余部分,我知道这一点,但这个应用程序是针对现代浏览器,因此,IE6是没有问题的。

I am writing a rather large JavaScript based application and sometimes there are cases when it has even eight (8) AJAX requests going on at once. This is a problem in IE6, because it kills the rest of the requests, I know that, but this application is targeted for modern browsers, so, IE6 is not a problem.

不过,我有一种感觉(没有做过任何实际的分析),该池的请求可能会产生更好的性能。再说,最多有4个请求的时间。

However, I have a feeling (have not done any actual profiling) that pooling requests could yield in better performance. Say, maximum of 4 requests at a time.

所以,我的问题是没有任何好处,汇集AJAX请求或者是好的有多个请求将在同一时间相比,有他们在那里处理了一个又一个池?

So, my question is that is there any benefit to pool AJAX requests or is it okay to have multiple requests going on at the same time compared to having a pool where they are processed one after another?

我知道这可能取决于浏览器和互联网连接,但我不知道这一点。

I realize that this might depend on the browser and Internet connection, but I am not sure about that.

推荐答案

IE6不会是你唯一的问题;其他浏览器也限制并发请求到同一服务器的数量。 这里有一个很好的综述,它说,作为该写默认值是:

IE6 isn't going to be your only problem; other browsers also limit the number of concurrent requests to the same server. Here's a good roundup, which says that as of that writing the defaults were:

Browser           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        4           4
Opera 10.00alpha  4           4

除此之外,从该条另外两个重要的报价:

Aside from that, two other important quotes from that article:

这是可能的重新配置您的浏览器使用不同的限制。

It’s possible to reconfigure your browser to use different limits.

请注意,IE8会自动回落到每台服务器2连接,为用户的拨号连接。

Note that IE8 automatically drops back to 2 connections per server for users on dialup connections.

......以及所有你知道的,其他现代的浏览器去做,也可以开始他们的下一个点发布这样做。

...and for all you know, other modern browsers do, or may start doing so with their next "dot" release.

如果可以的话,势必要保持长期开连接数降到最低。当然不积极保持多个连接打开很长一段时间。

If you can, definitely try to keep the number of long-standing open connections to a minimum. Certainly don't actively keep more than one connection open for a long time.

如果你只是做了很多个人的,快速的连接,有时他们聚成一团,你可能想自己连载他们,而不是依赖于浏览器来做到这一点。有一个负责做他们(一次)重新排队$ P $对象psenting需要做的请求,并code。

If you're just doing a lot of individual, quick connections and sometimes they bunch up, you probably want to serialize them yourself rather than relying on the browser to do it. Have a queue of objects representing the request that needs to be done, and code responsible for doing them (one at a time).