Using gunicorn w/ gevent, requests hang and workers throw [CRITICAL] WORKER TIMEOUT

1,904 views
Skip to first unread message

Akshar Dave

unread,
Oct 7, 2019, 8:01:20 AM10/7/19
to Google App Engine

When in the Google App Engine (flexible) environment, The request hangs and times out after 120 secs ... In the logs, I am getting [CRITICAL] WORKER TIMEOUT (pid:277) error when serving the Flask app with gunicorn and gevent workers. 

here is app.yaml:

runtime: python
env: flex
entrypoint: gunicorn -c gunicorn.conf.py -b :$PORT main:app

runtime_config:
    python_version: 3 

threadsafe: false
# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
automatic_scaling:
  min_num_instances: 5
  max_num_instances: 40
  cool_down_period_sec: 180
  cpu_utilization:
    target_utilization: 0.85

resources:
  cpu: 80
  memory_gb: 80
  disk_size_gb: 10

here is gunicorn.conf.py: 

import multiprocessing

workers = multiprocessing.cpu_count() * 2 + 1
keepalive = 120
timeout = 120
worker_class = 'gevent'
worker_connections = 1000
loglevel = 'debug'

here is requirements.txt:
Flask==1.0.3
gevent==1.4.0
gunicorn==19.9.0
google-cloud-bigtable
google-cloud-happybase
locustio==0.11.0
pyzmq==18.1.0

Yasser Karout

unread,
Oct 18, 2019, 3:42:37 PM10/18/19
to Google App Engine
I suggest trying to increase the timeout in the app.yaml to see if you can get requests to succeed if the timeouts are longer. If the requests succeed, the issue might be the code of the application, or you need more resources for it.
Reply all
Reply to author
Forward
0 new messages