@bergus
2017-01-05T02:31:27.000000Z
字数 4238
阅读 2098
优化
并发4个线程:uwsgi -s :9090 -w myapp -p 4主控制线程+4个线程:uwsgi -s :9090 -w myapp -M -p 4执行超过30秒的client直接放弃:uwsgi -s :9090 -w myapp -M -p 4 -t 30限制内存空间128M:uwsgi -s :9090 -w myapp -M -p 4 -t 30 --limit-as 128服务超过10000个req自动respawn:uwsgi -s :9090 -w myapp -M -p 4 -t 30 --limit-as 128 -R 10000后台运行等:uwsgi -s :9090 -w myapp -M -p 4 -t 30 --limit-as 128 -R 10000 -d uwsgi.log
命令行参数 uwsgi将gevent做为模块uwsgi -s 127.0.0.1:8080 --processes 4 --loop gevent --enable-threads --async 128 --disable-logging --wsgi-file test.pyuwsgi将gevent内置uwsgi --http :8080 --file test.py --gevent 2000 -l 1000 -p 1 -L 参数解释uwsgi将gevent做为模块uwsgi -s 127.0.0.1:8080 --processes 4 --loop gevent --enable-threads --async 128 --disable-logging --wsgi-file test.py如题谁有 uwsgi 的配置文件让我参考一下,我的配置老是出现 upstream prematurely closed connection while reading response header from upstream, client 这样的错误。 以下是我自己的配置: [uwsgi] #coding:utf-8uwsgi 启动时所使用的地址与端口socket = 127.0.0.1:8001master = true指向网站目录chdir = /obj1/wechat/profiler = trueenable-threads = truelogdate = truememory-report=truelimit-as = 6048daemnize = /obj1/wechat.logpython 启动程序文件wsgi-file = manage.pypython 程序内用以启动的 application 变量名callable = app处理器数processes = 4线程数threads = 2#状态检测地址 stats = 127.0.0.1:9191uwsgi_read_timeout = 600harakiri = 1200gevent = 100./uwsgi -w tests.cpubound_green -s :3031 --async 30 --ugreen./uwsgi -s :3031 -w simple_app --daemonize /tmp/mylog.log./uwsgi -s :3031 -w simple_app --logto /tmp/mylog.log# logto2 only opens the log file after privileges have been dropped to the specified uid/gid../uwsgi -s :3031 -w simple_app --uid 1001 --gid 1002 --logto2 /tmp/mylog.loguwsgi --gevent 100 --gevent-monkey-patch --http :9090 -M --processes 4 --wsgi-file wsgi.py%(uri) -> REQUEST_URI%(method) -> REQUEST_METHOD%(user) -> REMOTE_USER%(addr) -> REMOTE_ADDR%(host) -> HTTP_HOST%(proto) -> SERVER_PROTOCOL%(uagent) -> HTTP_USER_AGENT (starting from 1.4.5)%(referer) -> HTTP_REFERER (starting from 1.4.5)
# report uwsgi配置[uwsgi]base = /opt/report/dimension_reportapp = api.api_listenermodule = %(app)home = /opt/report/venvpythonpath = %(base)# processes = 16workers=16# lazy=Truesocket = /opt/report/dimension_report/%n.sock#socket = 127.0.0.1:1234chmod-socket = 644callable = applogto = /var/log/uwsgi/%n.log# report nginx 配置user centos;worker_processes 4;pid /var/run/nginx.pid;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;access_log /var/log/nginx/access.log;error_log /var/log/nginx/error.log;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;gzip on;gzip_disable "msie6";server {listen 80;server_name localhost;charset utf-8;client_max_body_size 75M;location / { try_files $uri @api_listener; }location @api_listener {include uwsgi_params;uwsgi_pass unix:/opt/report/dimension_report/app_uwsgi.sock;# uwsgi_pass 127.0.0.1:1234;}}}
# report service uwsgi[uwsgi]base = /opt/services/servicesapp = api.service_rest_apimodule = %(app)home = /opt/services/venvpythonpath = %(base)# processes = 16workers=12enable-threads=true# lazy=True# socket = /opt/services/services/%n.sockuwsgi-socket = 127.0.0.1:1122uwsgi-socket = 127.0.0.1:1123uwsgi-socket = 127.0.0.1:1124uwsgi-socket = 127.0.0.1:1125uwsgi-socket = 127.0.0.1:1126uwsgi-socket = 127.0.0.1:1127uwsgi-socket = 127.0.0.1:1128uwsgi-socket = 127.0.0.1:1129chmod-socket = 644callable = applogto = /var/log/uwsgi/%n.log# report service nginxuser centos;worker_processes 4;pid /var/run/nginx.pid;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;access_log /var/log/nginx/access.log;error_log /var/log/nginx/error.log;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;gzip on;gzip_disable "msie6";upstream uwsgicluster {server 127.0.0.1:1122;server 127.0.0.1:1123;server 127.0.0.1:1124;server 127.0.0.1:1125;server 127.0.0.1:1126;server 127.0.0.1:1127;server 127.0.0.1:1128;server 127.0.0.1:1129;}server {listen 80;server_name localhost;charset utf-8;client_max_body_size 75M;location / { try_files $uri @api_listener; }location @api_listener {include uwsgi_params;# uwsgi_pass unix:/opt/services/services/app_uwsgi.sock;uwsgi_pass uwsgicluster;}}}
快速部署Python应用:Nginx+uWSGI配置详解
nginx+uwsgi+flask配置记录
Managing the uWSGI server
在 Linux 下生成高强度密码的四种方法
