Recommended approach for deploying shiny for python

I’m looking for some guidance on how to deploy a shiny for python app in Shiny Proxy.

The demo launches the app via a gunicorn-wrapper in the docker RUN statement. However, the Posit docs explicitly states that you should avoid deployment configurations that do not support sticky sessions, like gunicorn (with >1 worker, not sure what the default is?).

Could someone please explain the reasoning behind the configuration used in the demo? As opposed to simply using something like : CMD ["shiny", "run", "src/app.py", "--host", "0.0.0.0", "--port", "8080"] (more or less equivalent to how R shiny apps are launched in their demo configs). Or even using uvicorn app:app --host 0.0.0.0 --port 80 as is recommended by the Posit docs?

Thanks in advance!

1 Like

Hi

Thanks for making us aware of this. We probably used gunicorn because it’s mentioned in the uvicorn docs: Deployment - Uvicorn :

  • Run gunicorn -k uvicorn.workers.UvicornWorker for production.

But I agree that if the shiny-for-python mentions to not use, we shouldn’t use it in the example. I updated the Dockerfile in the repo and also pushed a new image.

There is also an app that allows you to verify everything is working correctly. I tested this with both the old and new setup, and in both cases it’s working. So probably the old setup was fine as well, but of course it’s better to follow the best practices.

Great, I’ll give this a go! Thanks a bunch.