Dash_extensions and django-plotly-dash, how to combine

Hi All,

I have had great success using dash_extensions and the server side callbacks, speeding up the processing of my Dash app considerably (kudos to the developer @Emil!)

However, I have a need to expand my current use case to multiple dash apps, within a Django framework. I have been forced to go back to a straight dash app implementation using “django-plotly-dash” to inlay the app appropriately. The issue here is that I cannot now use the “dash_extensions” proxy to force the server side processing, and the app is now slow again.

Does anyone have any idea how I can either:

  1. use the django_extensions at the same time as Django framework (either with or without the django-plotly-dash" as well), or
  2. ensure that my Dash app within the Django framework runs processing, etc. on the server side?

Thank you! Let me know what further info might be useful here.

1 Like

Looks like dash_extensions does a number of things, not all of which will play nicely with Django, so one way forward could be to replicate the functionality that you need. In other words, the second option in your list is probably the easier path.

If your need is to keep objects server side (this is what I understand is underlying your performance issue) then one approach would be to explicitly use Django’s caching mechanism: generate an appropriate key (see below) and then store/access the object using the cache api. Using the same cache as the rest of the server will ensure your functionality remains working and scales appropriately if/when the server configuration is changed for multiple workers, server processes, etc.

You’ll want to use a key appropriate to your application - whilst dash_extensions has some mechanism for generating its cache key (someone familiar with the code can no doubt describe this) you will have to provide something that is appropriate for the level of sharing within your app across multiple app instances, users, etc.

1 Like

Hi Delsim,

Thank you for the response. I agree, using the django ecosystem would be preferable here.

I will try out the caching feature within django as ypu mention. As youve guessed, thia project includes some interactions that are relatively large in size so the server side processing is a must, performance is critical and quick interaction and response is key.

Cheers

As a follow up here, my new implementation is now working well using the low level API for caching from Django using one of the supported cache backends; it’s surprising how easy it is to use.

Thank you again @delsim!