Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gunicorn + nginx - Ignoring EPIPE

I have an nginx-gunicorn-flask setup running on google compute and I keep getting the following from gunicorn:

[2019-04-19 20:50:49 +0000] [3345] [DEBUG] POST /
[2019-04-19 20:50:49 +0000] [3345] [DEBUG] Ignoring EPIPE

out of 100 requests about 23 come out like that. In the access log only 23 requests show and they're all 200.

from nginx access logs show a 504 and in the error logs I see this:

2019/04/19 20:50:49 [error] 3097#3097: *295 upstream timed out (110: Connection timed out) while sending request to upstream, client: ip, server: , request: "POST / HTTP/1.1", upstream: "http://unix:/home/user/Server/server.sock/", host: "ip"

I tried setting

proxy_connect_timeout 75s;
proxy_read_timeout 300s;

on the location on nginx and --timeout 300 in gunicorn based on other questions but it didn't help.

The message from gunicorn isn't really helping determine the cause and I didn't find any info about it

Been trying to solve this for a while and I'd appreciate any ideas. Also each of these requests take about 1-2 seconds and jmeter shows a huge latency until the results show up.

Looking at gunicorn's code this is a errno.EPIPE exception having to do with the socket...

like image 860
K41F4r Avatar asked Apr 19 '19 21:04

K41F4r


People also ask

Can Gunicorn work without nginx?

Nginx Configuration Although there are many HTTP proxies available, we strongly advise that you use Nginx. If you choose another proxy server you need to make sure that it buffers slow clients when you use default Gunicorn workers. Without this buffering Gunicorn will be easily susceptible to denial-of-service attacks.

How does Nginx communicate with Gunicorn?

Nginx and Gunicorn work togetherGunicorn translates requests which it gets from Nginx into a format which your web application can handle, and makes sure that your code is executed when needed. They make a great team! Each can do something, which the other can't.

Why is Nginx required with Gunicorn?

Gunicorn implements the Web Server Gateway Interface (WSGI), which is a standard interface between web server software and web applications. Nginx is a web server. It's the public handler, more formally called the reverse proxy, for incoming requests and scales to thousands of simultaneous connections.

What is timeout in Gunicorn?

Gunicorn documentation about timeout Generally set to thirty seconds. Only set this noticeably higher if you're sure of the repercussions for sync workers. For the non sync workers it just means that the worker process is still communicating and is not tied to the length of time required to handle a single request.


1 Answers

I faced similar issues and timeout error, in addition with increasing timeout value, add Nginx config proxy_ignore_client_abort on; check this thread and Nginx doc

proxy_ignore_client_abort on;
like image 130
Rathish Kumar B Avatar answered Jan 05 '23 02:01

Rathish Kumar B