You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
botocore request/response times are much slower than expected in certain scenarios due to unexpected SSL overhead.
Expected Behavior
botocore /boto3 performs fast for all requests.
Ideally the first request does not take longer than any following requests (e.g. the SSLContext could be initialized during module init or be triggered by the user of the library in some way before any requests happen).
Current Behavior
Request/responses are too slow, see below.
Reproduction Steps
botocore performance is much slower than expected in certain scenarios. This can easily be reproduced by
Switching to sleep(5) yields fast requests again (except for the first one).
The reason for the slowness is that
the http keep-alive timeout that botocore uses implicitly via urllib3 seems to be rather low (probably between 5 and 10 seconds) and there doesn't seem to be a straightforward way to increase it. This causes an increased number of connection creations and ssl handshakes the as well as the issue mentioned in the next point.
enabling debug logging for urllib3 suggests that is_connection_dropped returns True for the connections that are issue after a sleep(10). So presumably something (the s3 server?) closed the connection. In this case there might not be a lot of things that botocore could do, except for the next point about making SSL connection creation faster.
The problem is even exacerbated when using a proxy as this leads to even more SSL calls. Adding different hosts to this makes the problem even worse as this leads to more HTTPConnectionPools being created.
Possible Solution
The solution for the http keep-alive timeout is to make this configurable somehow so that more requests can benefit from connection pooling.
The solution to avoid the overhead from load_verify_locations is probably to share the SSLContext across multiple invocations/threads. The requests issue I've mentioned above has a proposed workaround.
Additional Information/Context
No response
SDK version used
1.34.98
Environment details (OS name and version, etc.)
MacOS & Linux
Python 3.12.3
The text was updated successfully, but these errors were encountered:
Thanks for reporting this issue — after discussing with the team we decided that we should continue tracking this for further review and investigation.
tim-finnigan
added
p2
This is a standard priority issue
and removed
investigating
This issue is being investigated and/or work is in progress to resolve the issue.
needs-triage
This issue or PR still needs to be triaged.
labels
May 14, 2024
Describe the bug
botocore
request/response times are much slower than expected in certain scenarios due to unexpected SSL overhead.Expected Behavior
botocore /boto3 performs fast for all requests.
Ideally the first request does not take longer than any following requests (e.g. the SSLContext could be initialized during module init or be triggered by the user of the library in some way before any requests happen).
Current Behavior
Request/responses are too slow, see below.
Reproduction Steps
botocore performance is much slower than expected in certain scenarios. This can easily be reproduced by
which yields
This can be optimized by sharing the resource between iterations:
which yields
One can see that the initial request is always quite slow.
But the issue goes further. If there is some delay between requests all the requests get slow. This can be reproduced with:
This yields
Switching to
sleep(5)
yields fast requests again (except for the first one).The reason for the slowness is that
is_connection_dropped
returnsTrue
for the connections that are issue after asleep(10)
. So presumably something (the s3 server?) closed the connection. In this case there might not be a lot of things that botocore could do, except for the next point about making SSL connection creation faster.requests
are also affected, see Avoid reloading root certificates to improve concurrent performance psf/requests#6667 .The slow requests are slow, because
load_verify_locations
is called once for each of them. This happens through the urllib3PoolManager
/HTTPConnectionPool
and the recreation ofSSLContext
.You can verify this by running any of the above reproducers in a profiler and look at the number of calls to/time spent in
load_verify_locations
.Possible Solution
load_verify_locations
is probably to share theSSLContext
across multiple invocations/threads. Therequests
issue I've mentioned above has a proposed workaround.Additional Information/Context
No response
SDK version used
1.34.98
Environment details (OS name and version, etc.)
MacOS & Linux
Python 3.12.3
The text was updated successfully, but these errors were encountered: