Tuesday, 25 December 2018

Nginx/Uwsgi/Flask POST times out if body is too large

I'm using a dockerimage based on https://github.com/tiangolo/uwsgi-nginx-flask-docker/tree/master/python3.6. I am running a python app inside that accepts a POST, does some processing on the json body, and returns a simple json response back. A post like this:

curl -X POST http://10.4.5.168:5002/test -d '{"test": "test"}'

works fine. If, however, I post a larger json file, I get a 504: Gateway Timeout.

curl -X POST http://10.4.5.168:5002/test -d @some_6mb_file.json

I have a feeling that there is an issue with the communication between Nginx and Uwsgi, but I'm not sure how to fix it.

EDIT: I jumped inside the docker container and restarted nginx manually to get better logging. I'm receiving the following error:

2018/12/21 20:47:45 [error] 611#611: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 10.4.3.168, server: , request: "POST /model/refuel_verification_model/predict HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock", host: "10.4.3.168:5002"

From inside the container, I started a second instance of my Flask app, running without Nginx and Uwsgi and it worked fine. The response took approximately 5 seconds to be returned (due to the processing time of the data.)



from Nginx/Uwsgi/Flask POST times out if body is too large

No comments:

Post a Comment