✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Gunicorn deploy issue

Hi,

My Dash application show users the data in a SQL database and support pagination.

And I deployed it using gunicorn.

If I use 1 worker, it works. But if there are more than 1 workers, the pagination function does not work anymore.

The reason is that when I clicked the “Next page”, the worker to process the request may differ from the worker that process the previous request.

BTW, I tried both sync and async(gevent) workers in guncorn.

I thought this should be popular use case, but I can not find a good solution.

Please give suggestions how to deal with the issue, thanks in advance.

This is a general issue. If there is no solution for this, it means that Dash can not support interactive apps.

Dash is stateless by design so that you can scale up to N workers. Everything is stored in the client so that the necessary information is passed into each callback on any worker.

This model doesn’t work if you use ‘global’ variables as those mutable variables are unique to each worker process. This is explained in https://dash.plotly.com/sharing-data-between-callbacks

Thanks chriddyp for the reply.

Will check and get back later.

Thanks chriddyp again.

I did use ‘global’ variables that caused the problem

The issue solved

Thanks chriddyp again.

1 Like