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
When running a FastAPI app with uvicorn default settings, which uses uvloop, I started to notice that sometimes when handling multiple requests for the same path the response took longer than expected to arrive at the client. This issue became more noticeable when I tried using WebSockets to improve performance by returning the result in parts over the same connection instead of making multiple HTTP requests.
I made a mini FastAPI app that represents the situation of my app, a WebSocket client, and a HTTP Client.
I will try to work on a Minimal Reproducible Example.
PYTHONASYNCIODEBUG
in env?:I am opening this issue from an issue that I had previously opened in the uvicorn repository
When running a FastAPI app with uvicorn default settings, which uses uvloop, I started to notice that sometimes when handling multiple requests for the same path the response took longer than expected to arrive at the client. This issue became more noticeable when I tried using WebSockets to improve performance by returning the result in parts over the same connection instead of making multiple HTTP requests.
I made a mini FastAPI app that represents the situation of my app, a WebSocket client, and a HTTP Client.
I will try to work on a Minimal Reproducible Example.
Example Code
FastAPI App Code (server.py)
HTTP Client Code (http.py)
WebSocket Client Code (ws.py)
Experiment Instructions
Start server with uvloop (default)
Run clients
Start server with asyncio
Run clients
Results
uvloop
HTTP (some times the times are OK -> 3, 6, 9 and 12)
WebSockets
asyncio
HTTP (the grouping behavior was not observed in any attempt)
WebSockets
Environment
I am using Ubuntu 22.04 and a Python 3.12.5 environment created via conda (4.10.3).
pip freeze output:
The text was updated successfully, but these errors were encountered: