Joby Wilson Mathews
Joby Wilson Mathews

Reputation: 11116

Gunicorn worker getting restarted itself after long API calls

I have a flask application which is running using Gunicorn.

This flask application have an API which takes two hours to complete.

If the same API is called twice after a 30 minutes gap between two , then the process handling the first API call is getting restarted after the second API call.

Example: Initial process starts with API_1 After 30 mins API_1 is called again , then the process handling previous API_1 call is getting restarted.

Command used to start the Gunicorn server:

nohup gunicorn --bind 0.0.0.0:5000 --workers=8 run:app --timeout 7200  --preload> output.log& 

No of core : 8

I am not facing any issue while running flask in development mode.

Any idea why its behaving like this ?

Upvotes: 3

Views: 2741

Answers (1)

NavaneethaKrishnan
NavaneethaKrishnan

Reputation: 1318

You can use other types of worker. Your current worker type is sync. If you want to send a long request probably you must use a thread worker or async worker.

nohup gunicorn --bind 0.0.0.0:5000 -k gevent run:app

Refer to this document

Upvotes: 1

Related Questions