title: App Engine Flex deployment health check fails
body: <p>I've made a Python 3 Flask app to serve as an API proxy with gunicorn. I've deployed the openapi to Cloud Endpoints and filled in the endpoints service in the app.yaml file. </p>
  
  <p>When I try to deploy to app engine flex, the health check fails because it took too long. I've tried to alter the readiness_check's app_start_timeout_sec like suggested but to no avail. When checking the logs on stackdriver I can only see gunicorn booting a couple of workers and eventually terminating everything a couple times in a row. No further explanation of what goes wrong. I've also tried to specify resources in the app.yaml and scaling the workers in the gunicorn.conf.py file but to no avail. </p>
  
  <p>Then I tried switching to uwsgi but this acted in the same way: starting up and terminating a couple of times in a row and health check timeout.</p>
  
  <p>error:</p>
  
  <pre><code>ERROR: (gcloud.app.deploy) Error Response: [4] Your deployment has failed to become healthy in the allotted time and therefore was rolled back. If you believe this was an error, try adjusting the 'app_start_timeout_sec' setting in the 'readiness_check' section.
  
  </code></pre>
  
  <p>app.yaml</p>
  
  <pre><code>runtime: python
  env: flex
  entrypoint: gunicorn -c gunicorn.conf.py -b :$PORT main:app
  
  runtime_config:
      python_version: 3
  
  endpoints_api_service:
    name: 2019-09-27r0
    rollout_strategy: managed
  
  resources:
    cpu: 1
    memory_gb: 2
    disk_size_gb: 10
  </code></pre>
  
  <p>gunicorn.conf.py:</p>
  
  <pre><code>import multiprocessing
  
  bind = "127.0.0.1:8000"
  workers = multiprocessing.cpu_count() * 2 + 1
  
  </code></pre>
  
  <p>requirments.txt:</p>
  
  <pre><code>aniso8601==8.0.0
  certifi==2019.9.11
  chardet==3.0.4
  Click==7.0
  Flask==1.1.1
  Flask-Jsonpify==1.5.0
  Flask-RESTful==0.3.7
  gunicorn==19.9.0
  idna==2.8
  itsdangerous==1.1.0
  Jinja2==2.10.1
  MarkupSafe==1.1.1
  pytz==2019.2
  requests==2.22.0
  six==1.12.0
  urllib3==1.25.5
  Werkzeug==0.16.0
  pyyaml==5.1.2
  </code></pre>
  
  <p>Is there anyone who can spot a conflict or something I forgot in here? I'm out of ideas and really need help. It would also definitely help if someone could point me in the right direction where to find more info in the logs (I also run the gcloud app deploy with --verbosity=debug but this only shows "Updating service [default]... ...Waiting to retry."). I would really like to know what causes the health checks to timeout!</p>
  
  <p><strong>Thanks in advance!</strong></p>