Gunicorn: Gunicorn v 19 gives timeout for Flask http get request which taking time to execute

Created on 27 Apr 2019  ·  4Comments  ·  Source: benoitc/gunicorn

Version using : 19.7
Docker command to start server :
CMD ["gunicorn", "--workers=2", "-b 0.0.0.0:8080","--keep-alive=900","--threads=3","--max-requests=5","--graceful-timeout=900", "--log-level=DEBUG","executorengine.wsgi:app"]

Error details :
Critical timeout worker thread



502 Bad Gateway


The server returned an invalid or incomplete response.

Cosole logs

NFO:root:DONE:: Execute step operation with details ::

  | INFO:root:Start:: Rest GET method invoked on external system

Before complete action below new worker coming :)

  | [2019-04-27 10:11:00 +0000] [17] [INFO] Booting worker with pid: 17

Most helpful comment

If any one facing same issue please use below configuration

**

  • [ ] CMD ["gunicorn", "--workers=2", "-b 0.0.0.0:8080","--timeout=400","--threads=2", "-k=gevent","--log-level=INFO","

**

executorengine.wsgi:app"]

All 4 comments

If I understand correctly, you're saying that you have an incoming HTTP request to Gunicorn. When you handle that request, you in turn make an HTTP request to an external system, and that request takes long enough that your worker times out (the external system doesn't respond before your worker times out).

If that's what's happening, then I can think of two options:

1) Increase your worker timeout
2) Use an asynchronous worker, like gevent so that your external request doesn't cause a worker timeout.

@vaibhavpatil123 can you eventually try the master as well since cf8ac37ce41e530cc154f2c7cbccd84ccad4c242 has been merged.

Let us know

Finally I am able to fix my issue and now my request going through Flask server with below configuration.

CMD ["gunicorn", "--workers=2", "-b 0.0.0.0:8080","--timeout=400","--threads=2", "-k=gevent","--log-level=INFO","executorengine.wsgi:app"]

If any one facing same issue please use below configuration

**

  • [ ] CMD ["gunicorn", "--workers=2", "-b 0.0.0.0:8080","--timeout=400","--threads=2", "-k=gevent","--log-level=INFO","

**

executorengine.wsgi:app"]

Was this page helpful?
0 / 5 - 0 ratings