Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit the amount of connections per host #1517

Open
ShadowJonathan opened this issue Apr 1, 2022 · 3 comments
Open

Limit the amount of connections per host #1517

ShadowJonathan opened this issue Apr 1, 2022 · 3 comments

Comments

@ShadowJonathan
Copy link

This is kinda coming from #386, and probably/mainly also a request for hyper; I want to be able to limit the amount of requests that reqwest is making, concurrently, per host/IP.

The reasons for this is similar as in #386; too many requests are made at once, but unlike that issue, this is on a large process scale, where adding a semaphore to limit requests from all over the client would increase complexity a bit.

However, coming from python, this seemed like a "solved problem" for me; limit the amount of connections per host to a sane amount (10, or 20). Chrome does this as well (6 per host, with advantages gained by using HTTP2), however, it seems that reqwest and hyper do not limit themselves.

Even if opt-in, I'd like for there to be an option to limit the amount of pooled connections per host, to make hitting that "too many open files" error impossible.

@ghost
Copy link

ghost commented Dec 21, 2022

Is there some workaround to ensure that the amount of TCP connections per host is never over a certain limit? Amount of requests-in-progess could be anything, because HTTP 1.1 and HTTP 2 allow multiplexing, and the only issue here are the connections, right? @seanmonstar seeking your wisdom please.

@seanmonstar
Copy link
Owner

HTTP 1.1 and HTTP 2 allow multiplexing

Only HTTP/2 can multiplex.

Is there some workaround

Not that I'm aware off. This may be easier once hyper moves its pool into various pieces to live in hyper-util.

@ghost
Copy link

ghost commented Dec 21, 2022

Only HTTP/2 can multiplex.

Yeah, I guess it's better not to mix the terminology. I was trying to say that even though HTTP 1.1 pipelining isn't as convenient to use as HTTP 2 multiplexing, it still allows concurrent requests over the same connection.

This may be easier once hyper moves its pool

Good to know, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants