Improve performance of numConnectedSlots for connection pool #3904
Labels
1 - triaged
Tickets that are safe to pick up for contributing in terms of likeliness of being accepted
bug
t:client
Issues related to the HTTP Client
t:client-new-pool
t:core
Issues related to the akka-http-core module
Milestone
Testing a use-case that involves making requests to many different hosts I found it would occasionally get bogged down using 100% CPU with most of the threads having the following stack trace:
I'm not entirely sure why it occasionally happens, but seems like once it does it is a bit of a vicious cycle and it doesn't recover. I was using
superPool
and had a fairly largemax-connections
setting becausesuperPool
uses that for the parallelism. However,numConnectedSlots
is also linear to compute over the slots table which is sized based onmax-connections
. I have worked around this issue by not usingsuperPool
, but I think the pool implementation could also be improved to reduce the overhead. In particular, most of the time was spent in the check for pre-connect:One simple option might be to have
numConnectedSlots
work more likeIterable.sizeCompare(Int)
so it could short circuit quickly. In my casesettings.minConnections
was0
so it should be possible to avoid traversing at all.The text was updated successfully, but these errors were encountered: