乐闻世界logo
搜索文章和话题

How many concurrent AJAX ( XmlHttpRequest ) requests are allowed in popular browsers?

1个答案

1

In browsers, the number of concurrent AJAX (XmlHttpRequest) requests targeted at the same domain is limited. This limit is determined by the specific implementation of the browser. For most modern browsers, this constraint typically refers to the concurrent connection count per domain, rather than solely to AJAX requests.

For example, under HTTP/1.1, most browsers allow a maximum of 6 concurrent TCP connections per domain. This implies that theoretically, a browser can initiate up to 6 concurrent AJAX requests to a single domain. If more than this number is requested, additional requests are queued by the browser until one of the preceding requests completes.

Consider a scenario where your webpage needs to concurrently request 10 distinct resource files (such as JSON data), all directed to the same domain. When using modern browsers like the latest versions of Chrome or Firefox under HTTP/1.1, the browser will initiate the first 6 requests concurrently, while the subsequent 4 requests will be queued until one of the initial requests finishes before new requests are dispatched.

Notably, with the widespread adoption of HTTP/2 and HTTP/3, the connection limit becomes less restrictive because these newer HTTP protocols support multiplexing, enabling multiple requests to be sent in parallel over a single TCP connection.

These limitations are imposed by browsers to prevent excessive consumption of users' network bandwidth and server resources. When developing webpages that require concurrent processing of numerous requests, it is crucial to be aware of these constraints and adopt appropriate request management strategies, such as merging requests, utilizing Web Workers, or distributing requests across multiple subdomains to bypass these limitations.

2024年6月29日 12:07 回复

你的答案