3

I have the following stack for my application:

  1. NGINX (1.4.6)
  2. uWSGI (1.9.17.1-debian (64bit))
  3. Flask
  4. Python 3.4

The Problem After NGINX restart all works well for a period(few minutes). After that period I receive a "504 Gateway Time-out" error.

NGINX log:

*13 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 86.123.39.44, server: app.fc.com, request: "GET /dashboard/overview HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "app.fc.com", referrer: "http://app.fc.com/dashboard/overview"

uWSGI log:

app.fc.com [pid: 100017|app: 0|req: 103/219] 86.123.39.44 () {44 vars in 859 bytes} [Fri Mar 9 06:24:22 2018] GET /login => generated 245 bytes in 1 msecs (HTTP/1.1 302) 3 headers in 131 bytes (1 switches on core 1)

My NGINX configuration is:

server { listen 80; listen [::]:80; root /var/www/fc/website; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name app.fc.com; location / { sendfile on; client_max_body_size 20M; keepalive_timeout 0; proxy_connect_timeout 10; proxy_send_timeout 15; proxy_read_timeout 20; include uwsgi_params; uwsgi_pass 127.0.0.1:8001; #uwsgi_read_timeout 30; #uwsgi_send_timeout 30; uwsgi_connect_timeout 60; uwsgi_ignore_client_abort on; } } 

My uWSGI configuration is:

[uwsgi] vhost = true socket = :8001 #wsgi-file = /var/www/app.fc.com/reviewApp/wsgi.py wsgi-file = /var/www/fc/app/wsgi.py callable = app processes = 2 threads = 4 chdir = /var/www/fc/app/ pythonpath = /var/www/fc/app/ pythonpath = /var/www/py3/lib/python3.4 virtualenv = /var/www/py3 plugins = python3 

Usually, the response to my request last under 5 seconds

3
  • Did you check the uwsgi log? Commented Mar 9, 2018 at 11:17
  • @heemayl I have added the log from uWSGI Commented Mar 9, 2018 at 12:33
  • What if you remove uWSGI from the setup and serve the Flask app directly using NGINX? Just to help find the culprit. Commented Mar 9, 2018 at 12:38

1 Answer 1

1

The solution

I have discovered this behavior just on the page where Redis was called. I solved(short time solution) this by adding a new connexion at Redis for each request and setting up a connexion idle timeout in Redis config.

Other discoveries

Seems Redis hangs for about 931 seconds after 300 seconds of inactivity(which is the interval after this problem appeared) when the connexion is shared across many uWSGI threads.

Sign up to request clarification or add additional context in comments.

1 Comment

Same issue. i have a problem with beanstalkd connection.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.