Performance degrades under high load because of ConnectionNotAvailable exceptions #998
Replies: 1 comment
|
The observation is real, but excluding every connection that already has an assigned request would also throw away HTTP/2 multiplexing. Current pool assignment intentionally allows more than one queued request to be assigned to a connection for which So the proposed A robust optimization needs capacity-aware reservation rather than a boolean “already assigned” set. HTTP/1 has capacity one; HTTP/2 has dynamic capacity based on negotiated concurrent streams. Today I'd benchmark a fix that adds reservation/capacity semantics at the connection interface (or an equivalent atomic acquire) and include both cases in tests: high-contention HTTP/1 should stop producing avoidable retry exceptions, while concurrent HTTP/2 requests must still multiplex over a single connection. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I'm using httpcore in a project and while doing some performance tests with locust, I noticed, that the performance degraded under very high load. After digging, I found, that the AsyncConnectionPool may (and under load will!) assign connections to more than one pool_requests, which then results in ConnectionNotAvailable Exceptions (lots of them) which lowers the performance as the pool_request needs again to wait for an available connection.
I then made a simple modification in _assign_requests_to_connections so that already assigned connections are not considered as available, which greatly increased performance and totally got rid of ConnectionNotAvailable Exceptions.
Note: Only the 2 lines with the
assigned_connectionsvar were added/changed.My test results:
Don't know if this is the right fix to avoid the ConnectionNotAvailable Exceptions but it increases high load performance by more than 30 percent. I think it could be reasonable to keep two lists of connections, those which are available and those which are assigned - and move assigned connections accordingly.
What do you think?
All reactions