question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve performance by serving static assets directly

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
willemarcelcommented, May 26, 2020

@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.

0reactions
qeefcommented, May 26, 2020

@willemarcel I can’t find the solution in the repository. How have you solved it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance techniques for static content - Web application ...
There are many techniques used to increase a web application's static content performance. The chapter on performance and scalability techniques 101 introduced ...
Read more >
Improve Your Web App Performance By Serving Static Files in ...
Using static files compression sometimes really helps to improve your web performance. In my case, it really helps me to jump my app...
Read more >
Serve static assets with an efficient cache policy - GTmetrix
Serving static assets with an efficient cache policy helps improve page load times on repeat visits by storing these files locally in the...
Read more >
Using a CDN to Speed Up Static Content Delivery | DigitalOcean
A content delivery network can be a quick and effective solution for improving the scalability and availability of your web sites.
Read more >
Tips for serving static files faster, like JavaScripts, CSS and ...
To reduce the number of external resources in a page, you can also embed small images directly in your CSS files using base...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found