The Fix
Changed `RequestInfo` to be a `NamedTuple` to improve performance, making it 2.7x faster to create.
Based on closed aio-libs/aiohttp issue #9504 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+Changed ``ClientRequest.request_info`` to be a `NamedTuple` to improve client performance -- by :user:`bdraco`.
diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py
index 9c86d935011..59a191d19fe 100644
Option A — Apply the official fix\nChanged `RequestInfo` to be a `NamedTuple` to improve performance, making it 2.7x faster to create.\nWhen NOT to use: This fix is not suitable if backward compatibility with existing code is a concern.\n\n
Why This Fix Works in Production
- Trigger: """Update destination host, port and connection type (ssl)."""
- Mechanism: RequestInfo was implemented as a dataclass instead of a NamedTuple, affecting performance
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- RequestInfo was implemented as a dataclass instead of a NamedTuple, affecting performance
- Production symptom (often without a traceback): """Update destination host, port and connection type (ssl)."""
Proof / Evidence
- GitHub issue: #9504
- Fix PR: https://github.com/aio-libs/aiohttp/pull/9692
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.80
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.69
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“<img width="1500" alt="Screenshot 2024-11-05 at 8 42 07 PM" src="https://github.com/user-attachments/assets/92add3df-591f-4bfd-a138-db724e9414b6"> Production shows quite a bit of time making this one”
“I really doubt if we have the real bottleneck here”
“> Technically every namedtuple <-> attrs <-> dataclasses change is not 100% backward compatible, that's why I'm not super exciting in mutation of such things”
“This keeps coming up on production profiles so there is something there. It needs to be benchmarked and quantified first.”
Failure Signature (Search String)
- """Update destination host, port and connection type (ssl)."""
- <img width="1500" alt="Screenshot 2024-11-05 at 8 42 07 PM" src="https://github.com/user-attachments/assets/92add3df-591f-4bfd-a138-db724e9414b6">
Copy-friendly signature
Failure Signature
-----------------
"""Update destination host, port and connection type (ssl)."""
<img width="1500" alt="Screenshot 2024-11-05 at 8 42 07 PM" src="https://github.com/user-attachments/assets/92add3df-591f-4bfd-a138-db724e9414b6">
Error Message
Signature-only (no traceback captured)
Error Message
-------------
"""Update destination host, port and connection type (ssl)."""
<img width="1500" alt="Screenshot 2024-11-05 at 8 42 07 PM" src="https://github.com/user-attachments/assets/92add3df-591f-4bfd-a138-db724e9414b6">
What Broke
In production, creating RequestInfo instances led to performance bottlenecks.
Why It Broke
RequestInfo was implemented as a dataclass instead of a NamedTuple, affecting performance
Fix Options (Details)
Option A — Apply the official fix
Changed `RequestInfo` to be a `NamedTuple` to improve performance, making it 2.7x faster to create.
Fix reference: https://github.com/aio-libs/aiohttp/pull/9692
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not suitable if backward compatibility with existing code is a concern.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
- Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.