High TCPConnector.connect latency in aiohttp when running in Kubernetes #11255
Unanswered
ramundomario
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Does switching between ThreadedResolver and AsyncResolver show a change in behaviour? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
We're experiencing unexpectedly high latency during TCP connection establishment (
TCPConnector.connect
) when running our Python application usingaiohttp
client inside Kubernetes.Sometimes the
TCPConnector.connect
step takes approximately 15 seconds per request.When it happens, the number looks pretty static, with only minor variations (a few milliseconds), which suggests a systematic issue rather than random network delays.
Context
asyncio
+aiohttp
aio-pika
that consumes jobs from RabbitMQ and makes, in addition, HTTP requests to internal services usingaiohttp
.ndots
is set to1
so every URL must by FQDN.The HTTP client is created using
aiohttp.ClientSession
together withaiohttp.TCPConnector
for each request (we're not re-using theClientSession
nor theTCPConnector
)Observations
TCPConnector.connect
phaseforce_close
and otherTCPConnector
settings did not resolve the issue (as reported in aiohttp.ClientSession together with ClusterIp not load balancing #6629)TCPConnector.connect
, only 13 showed the long (~15s) latency.Traces are subject to sampling and do not represent total calls
Versions
3.11.18
3.11.13
Looking for help understanding this behavior and any guidance or best practices to mitigate the latency.
Any pointers on diagnosing, configuration, or known issues would be greatly appreciated.
Thank you for your support and for maintaining aiohttp!
Beta Was this translation helpful? Give feedback.
All reactions