我已经使用Flask Framework开发了Python应用程序,并使用NGINX和UWSGI将其部署在Ubuntu 18.02 Server上。
服务器功能强大,可以轻松处理大量用户,但是当30至40个用户与之连接时,服务器就会开始出现问题。
我检查了日志,没有看到任何应用程序错误,但是从NGINX和UWSGI方面,我看到了以下错误:
(虽然套接字文件也位于/ tmp /目录中)
我无法确定问题的根本原因是权限级别问题还是其他原因?您还可以在下面检查我的配置和ini文件:
这是我的默认nginx和mynginx配置,带有uwsgi.ini详细信息:
default-nginx.config
user www-data;
worker_processes auto;
pid /run/nginx.pid;
worker_rlimit_nofile 768;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 650;
send_timeout 120;
reset_timedout_connection on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
mynginx.config
server {
listen 80;
#server_name your_domain www.your_domain;
# location /socket.io {
# proxy_pass http://localhost:5000/socket.i;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header Host $host;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# }
location / {
# if ($request_method = 'OPTIONS') {
# add_header 'Access-Control-Allow-Origin' '*';
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
# add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
#
# Tell client that this pre-flight info is valid for 20 days
#
# add_header 'Access-Control-Max-Age' 1728000;
# add_header 'Content-Type' 'text/plain; charset=utf-8';
# add_header 'Content-Length' 0;
# return 204;#
# }
# if ($request_method = 'POST') {
# add_header 'Access-Control-Allow-Origin' '*';
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
# add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
# add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
# }
# if ($request_method = 'GET') {
# add_header 'Access-Control-Allow-Origin' '*';
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
# add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
# add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
# }
include uwsgi_params;
uwsgi_pass unix:/tmp/automate_prod_uwsgi.sock;
#proxy_pass http://myapp;
# proxy_read_timeout 120s;
# proxy_send_timeout 120s;
# when a client closes the connection then keep the channel to uwsgi open. Otherwise uwsgi throws an IOError
uwsgi_ignore_client_abort on;
uwsgi_read_timeout 500s;
}
}
uwsgi.ini
[uwsgi]
chdir = /home/tcrm/automate-prod
module = webapp
callable = theapp
master = true
processes = 1
#threads = 5
#http-websockets=true
#gevent=1000
#lazy-apps=true
single-interpreter=true
enable-threads=true
socket =/tmp/automate_prod_uwsgi.sock
#socket = 127.0.0.1:3031
chown-socket=www-data:www-data
chmod-socket = 666
vacuum = true
die-on-term = true
virtualenv = /home/tcrm/.virtualenvs/automate_prod_venv/
#http = 0.0.0.0:5000
#stats = 0.0.0.0:5001
#stats-http
#py-autoreload = 2
req-logger = file:uwsgi_request.log
logger = file:uwsgi_webapp.log
#pidfile = automate_uwsgi.pid
#daemonize = true
任何帮助将不胜感激,它已成为我PRODUCTION应用程序上的一个节目停止器。