Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore performance improvements in sync HTTP endpoints #690

Open
mxsasha opened this issue Oct 26, 2022 · 0 comments
Open

Explore performance improvements in sync HTTP endpoints #690

mxsasha opened this issue Oct 26, 2022 · 0 comments

Comments

@mxsasha
Copy link
Collaborator

mxsasha commented Oct 26, 2022

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:
Screenshot 2022-10-26 at 17 23 18

Sync endpoint:
Screenshot 2022-10-26 at 17 17 03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant