Replies: 4 comments 13 replies
-
Thank you for opening this discussion. Looking at your code sample, it seems to me that a new TCP connection is opened for each request, up to I have the feeling that it should probably not be the default behavior of a http/2 client to open up to 500 connections to a given host, so I think that there should be a way of tuning that behavior when initializing the client (and I would be in favor of keeping the default behavior as it is now). |
Beta Was this translation helpful? Give feedback.
-
Sorry, I think the variable naming has led to this confusion. Actually, I am not opening multiple TCP connections for each request, I am just limiting the no of active requests that are handled by a single http2 connection. I am suggesting that in addition to the above condition, we should add a check for active in-flight requests that are being handled by the connection, this in turn allows us to use multiple connections in a connection pool as now a single connection won't accept all the requests. |
Beta Was this translation helpful? Give feedback.
-
The HTTP/2 spec mandates opening a single connection to an origin, and using the stream multiplexing for multiple concurrent requests, rather than using multiple connections. We're careful to follow this in Have you taken a look at how the performance differs between HTTP/1.1 and HTTP/2 for your example use case? |
Beta Was this translation helpful? Give feedback.
-
Yes, I agree that http2 mandates opening a single connection to an origin, but the maximum concurrent requests that can be served on a single connection can be limited at client/server level using the Coming to my usecase, I am running a http client which needs to make bulk requests to a server which has an average response time of 300ms. I need to achieve an RPS of around 600 and for that I tried 3 combinations.
So I believe that the second approach provides the option to extract better performance out of the server by allowing the client to use multiple connections from the pool and we are not limited by the server's ability to handle concurrent requests on a single http2 connection. |
Beta Was this translation helpful? Give feedback.
-
Hey guys,
First of all, would like to thank you for the amazing work you guys have done here.
I was experimenting with async http2 connection pool for burst request handling, and I noticed that httpcore does not initialize more than 1 http2 connection in the pool ever as the is_available check for an http2 connection shall always return True until all the stream_ids (2^31 - 1) have been used.
This behaviour prevents us from using the full capabilities of the client as a single http2 connection has its own set of bottlenecks due to network bandwidth and we are not able to utilize multiple connections in the pool.
So I propose the following solution to maintain a state variable in http2 connection class called
active_connections
which will store the count of the current in-flight active requests, and check the current active connections inis_available
functionThis change has helped me improve the performance of my client by 2x and now we are able to support sending a bulk load of 5000 requests in 7 seconds as compared to 15 seconds using the older implementation by utilizing 10 connections instead of 1.
So I would request you to consider this solution and I would also like to work on the PR for the same.
Also, would love to discuss any other possible solutions for this problem.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions