[OpenStack] Reuse connections to same host/port #1886
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1885 1885.
If the connection host/port/secure hasn't changed then the current connection can be reused.
This greatly reduces overhead when doing bulk actions such as storage object downloads.
In testing with bulk downloading storage objects, this resulted in an overall 2x throughput increase.
Enables OpenStack connection reuse
Description
The underlying
common.base.Connection
object reuses connections (viaLibcloudConnection
-> Requests Session -> urllib3 connection pool) but the OpenStack's driver discards this every time it makes a new request. This results in a large amount of time spent opening connections and verifying SSL certificates. The proposed change only creates a new connection if any of the host/port/secure settings have changed.In theory, for HTTP-based providers there is never a need to explicitly create a new connection because the underlying Requests/urllib3 libraries will create new connections as needed. However, the underlying
LibcloudConnection
class treats host an immutable, so the session it creates will only ever be used for a single host/port. For this reason, we only need to re-connect()
when the host/port changes.Status
Done, ready for review.
Checklist (tick everything that applies)