Clarification of "simultaneous connections" limit.

Hi, do multiple simultaneous fetch requests each cost one "connection" towards the "simultaneous connections" limit, even if they are all to the same origin, and may be multiplexed? Similarly, are connections with the Caches or R2 APIs multiplexed? I would like to write a worker that checks for the existence of a potentially large number of items with one of these APIs, and would like to find a way to be able to check more than 6 in parallel at a time.
8 Replies
Hello, I’m Allie!
Yup, you can have six outbound connections at a time, even if they are all to the same destination. Though note that if you attempt to open more, it will just queue it up, so even if you make 100s of calls to an API in parallel, they will all complete, they will just run, at max, 6 at a time
nitsky
nitskyOP16mo ago
Any ways to increase parallelism? Theoretically, I could use connect() and implement HTTP/2 myself? 😛
Hello, I’m Allie!
Maybe? Might work, don’t know exactly how the TCP system interacts with the Limiters… Probably just a case of “try it and see”
nitsky
nitskyOP16mo ago
Do you know if the limiters count "open TCP connections" or "outstanding Cache, R2, and fetch requests"?
Erisa
Erisa16mo ago
Each TCP connection counts as a subrequest as far as limits are concerned
Hello, I’m Allie!
So if I open a TCP connection, and then make 20 HTTP requests through it, that counts as a single subrequest?
Erisa
Erisa16mo ago
Indeed
nitsky
nitskyOP16mo ago
Have you considered supporting multiplexed fetch requests or multiplexed requests with the R2 or Caches APIs to allow more concurrent requests? It would speed up my application significantly.
Want results from more Discord servers?
Add your server