good morning,
i new webserver infrastructures , administration. have following issue webserver try mount, using nginx + uwsgi + django , python: every refresh or request webpage user doing, uwsgi creates 2-3 new threads never terminate. after days, end more 30000 threads , have reload uwsgi in order maintain performance of webpage.
to check number of threads use following command: ps - elf | grep uwsgi (you can see result attached).
my uwsgi configuration following:
[uwsgi] vhost = true socket = /tmp/mysocket.sock master = true processes = 4 max_request = 300 vacuum = true die-on-term = true close-on-exec = true harakiri = 30 wsgi-file = /home/virtualenv/server/wsgi.py virtualenv = /home/virtualenv pythonpath = /home/virtualenv/myserver chdir=/home/virtualenv/myserver pidfile=/tmp/myfile.pid daemonize = /var/log/uwsgi/uwsgi-@(exec://date +%%y-%%m-%%d).log log-reopen = true chmod-socket = 664 gid = www-data uid = www-data
my uwsgi.py file following:
import os import sys path = ‘/home/virtualenv/myserver' if path not in sys.path: sys.path.append(path) os.environ['django_settings_module'] = 'myserver.settings' django.core.wsgi import get_wsgi_application application = get_wsgi_application()
and /etc/init/uwsgi.conf file is:
description "uwsgi emperor" start on runlevel [2345] stop on runlevel [!2345] respawn exec uwsgi --emperor /etc/uwsgi/vassals/ --wsgi-file /home/virtualenv/server/wsgi.py
i have tried using uwsgi , without threads, , without --thunder-lock nothing changes.
edit:
after cleaning uwsgi.ini file continue having same issue. current configuration of files is:
uwsgi.ini:
[uwsgi] socket = /tmp/mysocket.sock master = true processes = 4 max_request = 3 vacuum = true die-on-term = true close-on-exec = true harakiri = 30 wsgi-file = /home/virtualenv/server/wsgi.py virtualenv = /home/virtualenv pythonpath = /home/virtualenv/myserver chdir=/home/virtualenv/myserver pidfile=/tmp/myfile.pid logger = file:/var/log/uwsgi/uwsgi-@(exec://date +%%y-%%m-%%d).log log-reopen = true chmod-socket = 664 gid = www-data uid = www-data
uwsgi.conf
description "uwsgi emperor" start on runlevel [2345] stop on runlevel [!2345] respawn exec uwsgi --emperor /etc/uwsgi/vassals/
nginx.conf:
user www-data; worker_processes auto; worker_rlimit_nofile 10000; pid /run/nginx.pid; events { worker_connections 10000; multi_accept on; use epoll; } http { server_tokens off; resolver 8.8.8.8; map $http_accept_language $lang { default en; ~*en en; ~*pt pt; ~*fr fr; ~*it it; ~*es es; ~*ru ru; ~*ro ro;} client_body_buffer_size 10k; client_header_buffer_size 1k; client_max_body_size 10m; large_client_header_buffers 2 1k; client_body_timeout 12; client_header_timeout 12; keepalive_requests 100; send_timeout 10; open_file_cache max=2500 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on; sendfile off; tcp_nopush on; tcp_nodelay on; keepalive_timeout 5000; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; charset utf-8; gzip on; gzip_http_version 1.0; gzip_vary on; gzip_static on; gzip_disable ""msie6""; gzip_min_length 256; gzip_comp_level 1; gzip_buffers 4 32k; gzip_proxied any; gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }"
you're starting uwsgi emperor, shouldn't pass wsgi-file directly it. remove parameter uwsgi.conf file.
when using emperor, shouldn't daemonize uwsgi instances, because emperor loose connection it, causes spawning new instances on each request (emperor doesn't know there instances, because they've daemonized spawns new 1 handle requests). should remove daemonize
uwsgi configuration.
also, using vhost
when explicitly pointing wsgi file shouldn't done. if don't know parameter or don't think you're need it, remove it.
after changes, files should like:
uwsgi.ini file:
[uwsgi] socket = /tmp/mysocket.sock master = true processes = 4 max_request = 300 vacuum = true die-on-term = true close-on-exec = true harakiri = 30 wsgi-file = /home/virtualenv/server/wsgi.py virtualenv = /home/virtualenv pythonpath = /home/virtualenv/myserver chdir=/home/virtualenv/myserver pidfile=/tmp/myfile.pid log-reopen = true chmod-socket = 664 gid = www-data uid = www-data
uwsgi.conf file:
description "uwsgi emperor" start on runlevel [2345] stop on runlevel [!2345] respawn exec uwsgi --emperor /etc/uwsgi/vassals/
wsgi.py file won't change.
if want have logfile uwsgi server, use:
logger = file:/var/log/uwsgi/uwsgi-@(exec://date +%%y-%%m-%%d).log
instead of daemonize
.
Comments
Post a Comment