Hey All…
Right now I have a web app that has multiple pages with different dash plots. Each plot gets the data it needs to show from a database. For some of my more rapidly updating visuals, I am running in to database deadlock issues. Right now each function that generates tables/graphs is structured accordingly:
- Pull in SQL Data
- Process Data
- Generate Visual
So every time a callback on say a 5 second interval fires, it re-queries the database. If I have more than 7 or 8 instances of the same page open things significantly slow down.
What would be considered “best practice” in handling my data? I am a little confused about how to properly use dcc.Store. Am I able to execute all of my SQL data gathering server side (on a set interval) and have the graphs/visuals access one shared source? Its evident that the client side database querying is not the right way to go about all this.
Bump. Any help is much appreciated!
not sure i can help but can share some info thats helped with similar issues in the past .
Had an issue with long callbacks, shared callbacks and refiring off callbacks when switching pages. Got over the issue by caching using brain plasma GitHub - russellromney/brain-plasma: Shared-memory Python object namespace with Apache Plasma. Built because of Plotly Dash, useful anywhere. which might be helpful to you. If done again we would likely use a more supported alternative and i read there are flask options.
Also and different but kinda relevant, currently exploring a combination of dash with fastapi, and mongodb dash for front end and fastapi for calls to mongo the benefit here is that fastapi allows async calls to db so if you could possible use that to thread up calls and make them all at once
1 Like
Thanks for the reply, I’ll do some checking out!
edit: Just realized its only compatible with macOS/Linux. womp womp womp
I guess all I really need to do is set up a server side cache
sorry didnt notice that, I am running windows but go via docker - might be worth investigating that unless you are stuck to windows for enterprise reasons. Windows sucks for python dev and many other things
I think flask and pyarrow offer something similar but less out the box
1 Like
also I am looking to replace brain plasma to something more supported so will keep you posted
1 Like