-
Notifications
You must be signed in to change notification settings - Fork 241
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
HTTP client connection pool timeout doesn't free up queue #713
Comments
Roping in @alexander-yakushev in case they have a comment. It would be nice to cancel the pending acquire if it's taken too long, but it would also be fine w me to xform the rejected ex into a pool timeout ex. If you exhaust all conns in reality, you're going to get exceptions of some sort. |
I have a few comments about this indeed. I found that in practice (in my work, I can be biased), Aleph's approach to having a separate queue for acquiring connections is unnecessary. Caching connections is vital because you can't keep creating and disposing them at a high rate (due to TIME_WAIT), but limiting the total number of them is not as important. I personally set the connection limit to 16k per host and pool queue size to 0, so that a fresh connection is immediately created for the acquirer each time there are no free connections in the pool, up until the limit is hit at which point it's an error. There are some cases where you would use the pool with the queue as a parallelism controller. I think all those cases could be rewritten to something like Semaphores if Aleph connection pools offered no queueing. So, this is my take. In my world, the breaking Aleph2 would have connection pools with no acquisition queues. Such pools are much much easier to implement, way more performant at high loads, and give the user one less option and timeout to think about. But I understand that people can have other usecases where this won't fly. |
Sorry I haven't answered the original question. I think the current behavior is fine. I doubt anybody fine-tunes |
Thanks for chiming in @alexander-yakushev, very good insights! I agree that the acquire queue and timeout are quite awkward and needlessly complicate matters. I also agree that limiting parallelism should rather be handled by the caller/application itself. For example, if I'm already using As for status quo: Given all of the above, I think it's indeed fine to keep the behavior as-is. Closing but @KingMob feel free to re-open if you'd still like to see a change! |
Problem
The
pool-timeout
option ofaleph.http/request
controls how long the caller is willing to await a connection to be acquired from the connection pool. When it expires, the response deferred is rejected with aPoolTimeoutException
. However, the "acquire" operation will still clog up the pool's queue until it gets its (by then unnecessary) turn.Reproduction test case (in
aleph.http-test
):The second assertion fails with:
Solution
Eagerly removing the acquire operation from the pool's queue would require changing
io.aleph.dirigiste.Pool#acquire
to support this. Its (internal) queue already supports this viacancelTake
, it just isn't reachable from the public API.Alternatively: Perhaps the current behavior is fine / good enough? It just happened to surprise me but that could also be addressed with a docstring change.
The text was updated successfully, but these errors were encountered: