I have a Flask app (technically Dash) that use longish DB queries up to 5 minutes. When I run with the development server (by using python app2.py
), the app and DB queries run fine. But when I run the app with Gunicorn, no matter how I tweak the settings, the DB query times out, and the app does not run correctly.
I know that unlike the Flask development server, Gunicorn generally tries to avoid long I/O requests (like a DB query), but no matter how I change the timeout and worker type settings, nothing seems to fix the problem. I tried adding the number of workers and changing the worker type to gevent as I was researching that's better at handling I/O requests, but there is no change in behavior. Does anyone know what would solve this or where to even look? Below is the config I'm using to run Gunicorn, and also the failure message in the log when the DB query times out and spins endlessly. Also, I am running this on Ubuntu Server using SQLAlchemy in my Flask app to connect to a PostgreSQL DB. Thanks and let me know if you need any more details!
gunicorn --bind 127.0.0.1:8050 --workers 4 --worker-class gevent --timeout 600 app2:server
[29512] [CRITICAL] WORKER TIMEOUT (pid:29536)
[29512] [WARNING] Worker with pid 29536 was terminated due to signal 9