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.

Slow startup with many static files

See original GitHub issue

When multiple Django WSGI processes start in parallel accessing thousands of static files via network file system, it can take quite a while to seed the WhiteNoise.files static files cache, during which time the Django app can’t yet service inbound requests. (For example, we have server instances with 6 Django processes running Whitenoise 4.1.3 accessing ~4,000 static files via EFS (AWS-flavored NFS) which takes roughly 45 seconds to finish scanning the staticfiles dirs and begin accepting requests.)

I see the WHITENOISE_AUTOREFRESH setting to skip the cache initialization, but that’s labeled not for production use, and clearly adds ongoing overhead, as it stats every file at request time.

I wonder if there’s another configuration option we’re missing, if we’re using the tools incorrectly, or if you’ve considered adding another mode, where the WhiteNoise.files cache is lazy loaded incrementally as each file is requested?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
evansdcommented, Oct 26, 2020

I wouldn’t be totally opposed to adding support for it, but it would depend on how much complexity it adds and, specifically, how well-isolated that complexity is from everything else. This feels like one of those situations where adding basic support which works but with a few rough edges would be relatively easy, whereas getting something really solid which handles all the edge cases would be a lot more work.

I’d certainly be happy to reference your use case in the documentation though and link to any code you have. I’d say, get something that works for you by subclassing the middleware and then we can decide from there whether it looks worth trying to include in the main project.

1reaction
jbiggarcommented, Oct 25, 2020

Thanks for the thoughtful response @evansd.

Do you think a build/deployment-time-regenerated and initialisation-time-loaded pickle file cache is something you’d want to support in the main project? We’ll probably head down the path you suggest, but wouldn’t bother with a full PR to the upstream project if that’s not a direction you’d want to head.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Some Static Content Loads Very Slowly - Stack Overflow
I'm attempting to install an MVC 2 web application to our production server. This app has been run and tested on several test...
Read more >
Serving static files slowdown [SPR-16654] #21195 - GitHub
List API has no problem with new spring/spring boot. Problem is only with downloading images. We are downloading simultaneously multiple images, in summary ......
Read more >
Slow requests for random static files - cPanel Forums
I am running the current EasyApache 4 packages with mpm_prefork, php 7.2, and php-fpm. The problem exhibits itself on multiple sites, both ...
Read more >
Why is Nginx so slow at serving static files with ... - Server Fault
It turned out nginx was caching the downloads to disk, eventually filling it and causing the server to crash.
Read more >
Slow content download speed of static files using ...
I'll be setting up a CDN soon, but even in the case of a cache-miss the (periodically) slow download speed would make most...
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