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
Uvicorn/starlette can handle both sync and async endpoints, but there may be inefficiencies in their handling of sync endpoints. See attached screenshots for the same code, sync vs async endpoint, where the async version just called execute_query in a basic @sync_to_async wrapper, i.e. the actual database call is still sync, and remove_auth_hashes and (json) encode are just CPU bound. The async endpoint is 5 times faster.
Perhaps this is a weird case, perhaps it's only because this endpoint was pushing 2 GB of JSON through StreamingResponse, but it's worth experimenting with this for our other endpoints.
Async endpoint:
Sync endpoint:
The text was updated successfully, but these errors were encountered:
Uvicorn/starlette can handle both sync and async endpoints, but there may be inefficiencies in their handling of sync endpoints. See attached screenshots for the same code, sync vs async endpoint, where the async version just called
execute_query
in a basic@sync_to_async
wrapper, i.e. the actual database call is still sync, andremove_auth_hashes
and (json)encode
are just CPU bound. The async endpoint is 5 times faster.Perhaps this is a weird case, perhaps it's only because this endpoint was pushing 2 GB of JSON through
StreamingResponse
, but it's worth experimenting with this for our other endpoints.Async endpoint:
Sync endpoint:
The text was updated successfully, but these errors were encountered: