WSGIMiddleware overhead #24
Replies: 2 comments
-
Maybe you can get a better comparison by testing the performance of the original flask. You are welcome to submit any PRs that improve performance. Here's a performance benchmark I just ran.
|
Beta Was this translation helpful? Give feedback.
-
I tried this. gunicorn main:flask_app --bind=:8000 -w 1
At 23.58 reqs/s, pure Flask is even faster than the ASGI implementation. This is not a fair comparison of ASGI vs WSGI, as the ASGI code is running synchronous code.
I haven't found anything yet to improve performance, I'll spend some time this weekend and see what's possible. |
Beta Was this translation helpful? Give feedback.
-
I'm exploring the feasibility of moving an existing Flask app to FastAPI while running the old Flask app using the WSGIMiddleware.
I've been running some performance tests and there's a very significant overhead that WSGIMiddleware brings to the mix. I wrote a small demo here.
This is how I run the server:
There are two endpoints:
/users_fastapi
(direct, no middleware) and/users_flask
(wsgi middleware). Both endpoints query some dummy data from the in-memory db and return it as a response.The direct route has a throughput of 17.08 reqs/s, and the one behind wsgi middleware only goes up to 7.39, which is a significant difference.
I'm looking at the middleware and trying to figure out if there's room to reduce overhead, however, any inputs or ideas are much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions