-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Introduce pre-opening of connections in MultiplexedConnectionPool #3248
Comments
Is this really necessary? Isn't it just configuration that setups with low values for |
@gregw it's not just low |
@sbordet so how do you see this working:
|
My initial thought is to have something similar to ThreadPoolExecutor.prestartAllCoreThreads(). A configurable setter with |
So having a prestart call suggest that there will also be a minimum connections configuration? Otherwise you will be able to prestart, then idle timeout will close all the connections and a burst that arrives after a pause will still suffer. In fact the pool is going to have to actively close and refresh connections, because simply ignoring idle timeouts is not sufficient as the other end will probably close the connection. Thus we will need a minimum number of connections and when an idle timeout fires, we need to close a connection and create a new one. We then need a way to stagger such reconnections so they don't all happen at once. |
@gregw not keen to have a "ping" request to keep the connections open. The idea would be that when one closes, another is opened to keep a minimum number of connections open. Randomizing the idle timeout on the client seems complicated and may lead to unexpected behavior for those that count on the idle timeout to be somehow precise. Yes we may have an unlucky window where N connections that were never used all idle timeout and close at the same time, but it should not be that complicated to spread their openings. So perhaps we need Thoughts? |
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The use case would be to pre-create the connections because you know you're going to use them, but then they will undergo the usual logic for idle timeout and eventually the pool could go back to zero connections opened. I'm not sure we should provide more complicated behavior for now, such as @gregw further thoughts? |
This issue has been automatically marked as stale because it has been a |
HTTP/2 requires an additional roundtrip to open a connection, where the client needs to send the preface and wait for the server preface (see #2672).
In case of a spike of requests, it may be possible that
HttpClient.maxRequestsQueuedPerDestination
is exceeded while the connections are being opened.Pre-opening connections during startup may allow the client to tolerate the request spike without overflowing the request queue.
The text was updated successfully, but these errors were encountered: