Deploy to the web a Dash App with Diskcache

hi Render community members,
I would like to recommend to my community of ~30k Dash users on YouTube the usage of render instead of Heroku for Dash app deployment to the web.

I’ve deployed a Dash app twice through render’s free tier successfully.

However, when trying to deploy this current dash app that is running a background callback and diskcache, it gave me the following error.

File “/opt/render/project/src/.venv/lib/python3.7/site-packages/dash/long_callback/managers/diskcache_manager.py”, line 40, in init
from missing_imports
ImportError: DiskcacheLongCallbackManager requires extra dependencies which can be installed doing
$ pip install “dash[diskcache]”

As you can see from the requirements.txt file, I declared dash[diskcache]==2.6.1, and this is the gunicorn start command I’m using: gunicorn app:server worker: celery app

The confusing thing is that I deployed the same repo/app successfully to the web using heroku’s free tier, so I’m not sure what needs to be updated for it to work with Render.

What about trying to include the dependencies for diskcache directly as per https://github.com/plotly/dash/blob/dev/requires-diskcache.txt ?

John B

Thank you for this @John_B
I was able to deploy the app by adding these lines of code to the requirements file that you suggested:

diskcache>=5.2.1
multiprocess>=0.70.12
psutil>=5.8.0

That said, the app stops working after a few clicks on the background callback button. Do you know if one can run background workers on a free tier? Or could it be because “Disks are not supported for free plan services?”

You can’t run a background worker on a free plan, no. Webservices only.

John B

1 Like