8

Background

I've noticed that almost all proxy providers have the concept of "Maximum threads" allowed, which from my understanding means maximum number of concurrent/parallel browser requests at a time. Since a modern website can have many parallel requests, how can I put a limit in Chrome on parallel requests (globally for the entire browser, not only per host/server, but for all of them combined)?

Example

Website A is getting resources from its own domain, and besides that uses 9 CDNs and 10 trackers. Let's say Chrome has max 6 concurrent requests / domain, so that's 120 concurrent requests. Anything above this has to wait its turn. I would like to limit this to a maximum of 10 for example.

Notes

I've seen that in Firefox it can be done with 'network.http.max-connections' but I didn't manage to find anything for Chrome or Chromium.

I'm using Selenium and ChromeDriver (C#) to launch the browser, if it helps.

Code
  • 355
  • 6
  • 18

2 Answers2

5

after some digging and searching i found out that for Chromium Many of network tune parameters are in ClientSocketPoolManager check lines : 29 and 46, So i think You will need to rebuild your own custom Chrome with your preferred parameter rather than be able to dynamically tune them.

Asmoun
  • 1,417
  • 5
  • 20
  • 53
  • 1
    Thanks a lot! This parameter could be moved to the command line, rather than just rebuilding the Chrome with another constant. But I can take it from here. – Serge Rogatch Aug 06 '20 at 04:21
0

Browser connection limitations

Browsers limit the number of HTTP connections with the same domain name. This restriction is defined in the HTTP specification (RFC2616). Most modern browsers allow six connections per domain. Most older browsers allow only two connections per domain.


The HTTP/1.1 RFC

The Section 8.1.4 of the HTTP/1.1 RFC mentions that:

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.

Modern browsers are less restrictive than this allowing a larger number of connections. The RFC does not specify how to prevent the limit being exceeded. Either connections can be blocked from opening or existing connections can be closed.


Settings for Current Browsers

Steve Souders in his article Roundup on Parallel Connections provided the number of connections per server supported by current browsers for HTTP/1.1 as well as HTTP/1.0 which is as follows:

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
Chrome 4+               6           ?
iPhone 2                4           ?
iPhone 3                6           ?
iPhone 4                4           ?
Opera 9.63,10.00alpha   4           4
Opera 10.51+            8           ?

It is possible to reconfigure your browser tweaking the MaxConnectionsPerServer and MaxConnectionsPer1_0Server settings in the Windows Registry control the number of connections per hostname for HTTP/1.1 and HTTP/1.0 respectively.

In Firefox these values can be controlled by the network.http.max-connections and network.http.max-connections-per-server settings in about:config.

Now to Match Firefox's per-host connection limit of 15 Chromium/Chrome team tried to match the same and went through the discussion Configurable connections-per-host but ended up without any conclusions.


Conclusion

The same standards are also applicable while you use any of the WebDriver and Web Browser variant combo. The behavior with Selenium Grid Setup, Chrome Headless and Firefox Headless will also be identical.


References

Community
  • 1
  • 1
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 2
    This doesn't answer the question, in the shortest form, how to limit to 1 the number of simultaneous connections from a browser. – Serge Rogatch Aug 03 '20 at 14:41
  • 1
    Not only does it not answer the question but it also uses URLs from 2008 – Code Oct 05 '20 at 08:55