1

As usual, i have another very weird issue. I have a NGINX webserver that is accessible from anywhere.It is serving my python file with the help of uWSGI. Within the python file i make use of the mysql-connector library to get information from a mysql database that is running on the same machine. (The machine is a raspberry pi running raspbian). I have an index page that just returns a string and a /resources page that connects with the database and returns some information in json.

After give or take 15 minutes everything breaks down. The server becomes unesponsive and shows the 'Bad gateway' error or the 'a time out occured' error. I restarted just the uWSGI to narrow down the cause and doing so brings my app back online again. This means it's either that or my flask server somehow.

I used the following link: I used the following link: http://vladikk.com/2013/09/12/serving-flask-with-nginx-on-ubuntu/

I find it VERY difficult to find information about this. What could it be? How could i troubleshoot this? What are possible fixes?

UWSGI Logfiles

clock source: unix detected number of CPU cores: 4 current working directory: /home/pi detected binary path: /usr/local/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! * WARNING: you are running uWSGI without its master process manager your processes number limit is 7336 your memory page size is 4096 bytes detected max file descriptor number: 65536 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uwsgi socket 0 bound to UNIX address /var/www/demoapp/demoapp_uwsgi.sock fd 3 Python version: 2.7.9 (default, Sep 17 2016, 20:55:23) [GCC 4.9.2] Set PythonHome to /var/www/demoapp/venv Python threads support is disabled. You can enable it with --enable-threads Python main interpreter initialized at 0x67b490 your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 64256 bytes (62 KB) for 1 cores Operational MODE: single process added /var/www/demoapp/ to pythonpath. WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x67b490 pid: 32459 (default app) uWSGI is running in multiple interpreter mode * spawned uWSGI worker 1 (and the only) (pid: 32459, cores: 1)

7
  • Mmmm... Interesting. How many uWSGI workers or threads do you have running? You should have at least 3 workers. Also, is there any information in the log files (NGINX, uWSGI, flask)? Commented Nov 1, 2016 at 9:02
  • Thank you for taking the time. I have added the last couple rows of the log files. It appears i just have 1 worker. How come 1 worker blocks so quickly though? And how do I add more? Commented Nov 1, 2016 at 9:10
  • 1
    One worker will block because usually, you'll have a worker accepting requests and one performing I/O operations, viz reading from a database in your case. Because you only have one worker, this becomes problematic. See the docs for some tips (you may search for processes on this page). You can increase the number of workers by using the -p num option from the command line, or processes = num from a configuration file (num is the integer number of processes you want). Let me know if you need additional clarification. Commented Nov 1, 2016 at 9:20
  • Thanks a lot Keenan! It seems to have fixed the issue! Commented Nov 1, 2016 at 9:28
  • Hi Keenan, actually, the problem is back. The performance has increased but the server still times out after 15 / 30 minutes... Commented Nov 1, 2016 at 11:58

1 Answer 1

2

This is a worker blocking issue.

One worker will block because usually, you'll have a worker accepting requests and one performing I/O operations, viz reading from a database in your case. Because you only have one worker, this becomes problematic.

See the docs for some tips (you may search for processes on this page). You can increase the number of workers by using the -p num option from the command line, or processes = num from a configuration file (num is the integer number of processes you want).

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.