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.
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.
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:
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 --keep-alive 65 --workers 2 --threads 2 --bind 0.0.0.0:8000 dashapp:server, etc.
However, none of this brought any results.