Improve performance by serving static assets directly
See original GitHub issueHi,
as mentioned in my comment on one of the earlier commits, it looks like Tasking manager performance could be (potentially significantly) improved if it didn’t use Python to serve static assets like JavaScript files, SVG icons etc. instead of delegating the work to the web server.
Serving static content through Python means that the application has to read (potentially relatively large) files from the disk, buffer them and send them as a response through WSGI to the client. This takes time and blocks Python workers from serving other requests.
The Flask documentation for the send_from_directory
function explicitly warns of this approach and recommends to handle static assets separately:
It is strongly recommended to activate either X-Sendfile support in your webserver or (if no authentication happens) to tell the webserver to serve files for the given path on its own without calling into the web application for improved performance.
I believe it’s worth giving it a try because the performance issues we experienced earlier this week at the time when several tens of people were using TM resembled overloaded python workers trying to serve every request (even those that could have been handled by the web server itself). It would be nice if someone could have a look at it.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:15 (7 by maintainers)
Top GitHub Comments
@qeef on AWS, we build the frontend and serve it through a CDN instead of the gunicorn server. The views yet exist on the backend though.
@willemarcel I can’t find the solution in the repository. How have you solved it?