Nginx / gunicorn connection for 60 seconds

I am making an HTTP POST request against the nginx-> gunicorn-> Django application. The response body returns quickly, but the request does not end completely for another 60 seconds.

Upon completion, "I mean that the various clients I tried (Chrome, wget, the Android application I create) indicate that the request is still running as if expecting more data. Listening from Wireshark I see that all data arrives quickly, and then after 60 seconds, ACK FIN finally appears.

The same POST request on the local development server ( ./manage.py runserver) is fast. In addition, it quickly starts against gunfire, bypassing nginx. Also works fast in Apache / mod_wsgi settings.

GET requests have no problems. Even other POST requests are fine. One difference that I know of is that this particular query returns 201 not 200.

I believe that it relates to headers Content-Lengthclosed vs keepalive connections, but still does not know how things should work correctly.

  • The backend server (gunicorn) is currently closing the connections, this makes sense.
  • Should the backend server enable Content-Length headeror Transfer-encoding: chunked? Or can nginx manage without them and add them as needed?
  • I assume that keep-alive communication is good and should not be disabled in nginx.

: keepalive_timeout 0 nginx.conf . , , . , . , - ( Django gunicorn) chunked transfer .

+3
1

, upstream (gunicorn) - api - , ( , ), proxy_read_timeout nginx 60 , - .

, POST .

, return HttpResponse(status=201) - , Django : return HttpResponse("", status=201) . - , - -, .

0

All Articles