0
votes

I was working on deploying my web application via Google App Engine when I encountered a 502 Bad Gateway Error(Nginx). After running gcloud app logs read, I tracked the error down to be:

2020-05-12 00:15:59 default[20200511t163633] "GET /input/summary" 200

2020-05-12 00:16:38 default[20200511t163633] [2020-05-12 00:16:38 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:9)

2020-05-12 00:16:38 default[20200511t163633] [2020-05-12 00:16:38 +0000] [9] [INFO] Worker exiting (pid: 9)

2020-05-12 00:16:38 default[20200511t163633] [2020-05-12 00:16:38 +0000] [15] [INFO] Booting worker with pid: 15

2020-05-12 00:16:38 default[20200511t163633] "POST /input/summary" 502

For those wondering, my app.yaml looks like this:

    runtime: custom
    env: flex
    
    runtime_config:
      python_version: 3
    
    resources:
      cpu: 4
      memory_gb: 16
      disk_size_gb: 25
    
    readiness_check:
      app_start_timeout_sec: 900

My Dockerfile looks like this:

FROM gcr.io/google-appengine/python

RUN virtualenv /env -p python3.7

ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH

ADD requirements.txt /app/requirements.txt
RUN pip3 install -r /app/requirements.txt

ADD . /app

RUN apt-get update \
    && apt-get install tesseract-ocr -y

EXPOSE 8080
ENTRYPOINT ["gunicorn", "--bind=0.0.0.0:8080", "main:app"]

I am running the app through:

    if __name__ == '__main__':
        app.run(debug=True, host='0.0.0.0', port=8080)

Everything seems to work fine on localhost but the problems arise when I deploy to Google App Engine. Does anyone know what may be the root of the issue? Thanks in Advance!

1
By default, Gunicorn uses sync workers and each worker can only handle one request at a time. By default, gunicorn only uses one of these workers. I would suggest to check Google Documentation with the recommended gunicorn configuration. Let me know if this works for you. - tzovourn

1 Answers

0
votes

Is it failing to deploy? Or does the deploy succeed, but the server fails to run?

If its failing to deploy, you may be hitting the 10 minute timeout that deploy jobs have to finish. You can increase this number by setting your local gcloud config.

gcloud config set app/cloud_build_timeout 1200s