Increased delay when updating library versions (Dash 1.19.0 vs Dash 2.9.2)

I recently updated all the libraries in the project with the expectation of getting better performance, but I got an increased page load delay of up to 10 seconds in certain places. Before this I had dash==1.19.0 and updated to dash==2.9.2.

Below I’ll list a few older libraries and their versions, followed by a list of the versions I’ve upgraded to.

Old versions:
dash==1.19.0
dash-auth==1.4.1
dash-bootstrap-components==0.11.3
dash-core-components==1.15.0
dash-html-components==1.1.2
dash-renderer==1.9.0
dash-table==4.11.2
dash-daq==0.5.0
dash-extensions==0.0.46
plotly==4.14.3
Flask==1.1.2
Flask-Compress==1.9.0
Flask-Login==0.5.0
Flask-Migrate==2.7.0
Flask-SeaSurf==0.3.0
Flask-SQLAlchemy==2.5.1
Flask-WTF==0.14.3
Flask-CeleryExt==0.4.3
gunicorn==20.0.4
Jinja2==2.11.3
Werkzeug==1.0.1

New versions:
dash==2.9.2
dash-auth==2.0.0
dash-bootstrap-components==1.4.1
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-renderer==1.9.1
dash-table==5.0.0
dash-daq==0.5.0
dash-extensions==0.1.13
plotly==5.14.1
Flask==2.2.3
Flask-Compress==1.13
Flask-Login==0.6.2
Flask-Migrate==4.0.4
Flask-SeaSurf==1.1.1
Flask-SQLAlchemy==3.0.3
Flask-WTF==1.1.1
Flask-CeleryExt==0.5.0
gunicorn==20.1.0
Jinja2==3.1.2
Werkzeug==2.2.3

I suspect that the reason may be the incompatibility of certain libraries, but I did not find any information about this. These are the main libraries that I believe may be causing this behavior, however this is not a complete list of what is used in the project and has been updated, so I can provide complete lists if needed.

Maybe the Flask version is too new or somehow not compatible with Dash? Because I saw that Dash 2.10 will automatically install the correct version of Flask to prevent various issues.

I would be very grateful if someone could tell me what could be the reason or in which direction to look.

1 Like

Hi @dmytro.koziuberda - I have not seen an increased delay like that before - very frustrating! And just to confirm, this is page load, as opposed to app startup time? Meaning every time you load the page you get a delay that might be as long as 10 seconds?

It’s possible some logic changed about which callbacks execute on page load, and now your app is running a heavy computation that previously only happened after some user interaction. If that’s the case, you’d need to identify that callback and ensure it has prevent_initial_call=True. Regardless, I would debug this by opening a new browser tab (I’m assuming Chrome but the others will be similar), loading the devtools to the network tab, and loading the page. This will show you all the network requests and you can see which ones are taking a lot of time, in the “waterfall” column. It’s best to do this test with debug turned off, or at least hot reloading disabled, otherwise the _reload-hash requests will keep firing every couple of seconds and make it hard to see the loading activity. If the slow one is a _dash-update-component request, that’s a callback, and if you click on it, the data should show which callback it is.

Here’s the network tab when I load dash.plotly.com - it’s a pretty darn heavy app since it includes essentially every library we make as well as some third-party components, it’s running most of the same versions you’ve upgraded to, and it loads in 2-3 seconds on my computer. You can see a _dash-update-component request in the middle:

4 Likes

Hi, @alexcjohnson, thank you for such a quick response.

Yes, I’m talking about loading the page.

Here is an example. In the first screenshot, the loading takes 12 seconds (with old versions of the libraries), and in the second, it takes almost 20 seconds (with new versions). An increase in latency by almost 2 times, while there is no single _dash-update-component request that takes most of the time.

In my opinion, judging by the “Network” I saw when reloading pages with different versions several times, for Dash 2.9.2 almost all my _dash-update-component requests began to be executed longer. At the same time, I tried adding prevent_initial_call=True to almost all my callbacks at the same time and it did not affect the page load time at all.

I also tried:

  • Downgrade Flask and its dependent libraries;
  • Downgrade Python version from 3.11.2 to 3.9.6;
  • Run the application with various gunicorn command options, like gunicorn dashapp:server --workers 13 -b localhost:5000, gunicorn dashapp:server, gunicorn --keep-alive 65 --workers 2 --threads 2 --bind 0.0.0.0:8000 dashapp:server, etc.

However, none of this brought any results.