_dash-update-component randomly waits 1 minute before loading data

I have build up a simple application with 2 pages (multi page dash app) which I am running locally using gunicorn with 2 workers 4 threads. Its a simple dashboard application.

When I refresh the page in the browser and inspect the network tab, it usually takes 800ms to use the data and render it to the chart (_dash-update-component took 800ms to respond/finish).

However there are instances when I reload, it takes 1 minute to do the same process. The page is an empty white page with just “Loading…” text to it. Sometimes it hogs at dash-dependencies as well.

Hello @hqur

Welcome to the community!

I believe that you are encountering a conga line to requests. This works because each request gets in line and gets rendered on a first come first server basis, so if it is last in-line then it will take a while to get the response.

There are several things that you can do to avoid this:

  1. use a reverse proxy (I use nginx) with a config that offloads static pages (assets, static and dash-component-suites):
location /static {
   expires 120m;
   add_header Cache-Control "public";
   gzip_static on;
   alias ${RUNNER_DIR}/static;
 }

 location /_dash-component-suites {
   expires 1y;
   proxy_cache cache;
   proxy_cache_lock on;
   proxy_cache_lock_age 30s;
   proxy_cache_lock_timeout 30s;
   proxy_cache_valid 200 1y;
   gzip_static on;
   proxy_buffering on;
   uwsgi_buffering off;
   proxy_redirect off;
   proxy_http_version 1.1;
   add_header Cache-Control "public, max-age=30672000";
   proxy_pass http://backend; # this is your dash app location
   include /etc/nginx/proxy_params;
 }

 location /assets {
   expires 1y;
   add_header Cache-Control "public; max-age=30672000";
   gzip_static on;
   alias ${RUNNER_DIR}/assets;
 }
  • Component suites and assets both get timestamps, so cache busting. Static doesnt get anything like that automatically. But this approach allows for the server to only handle things that its really needed for.
  1. I’d also make sure that your app isnt crashing silently or running in debug mode, as both of these would cause the server to reboot and take much longer to respond to requests.
1 Like