dem*_*rms 8 django nginx gunicorn
我有一个通过 Nginx/Gunicorn 提供服务的 Django 应用程序。在加载某些页面时,Gunicorn 的 CPU 使用率会飙升至 100% 并完全降低性能,导致页面加载时间为 10 秒。
我没有进行任何数据库调用 - 我已经加载了所有结果memcached
。它应该非常快,所以这种疯狂的减速是疯狂的。
gunicorn_start:
NAME="name" # Name of the application
MAINDIR=/opt/name/
DJANGODIR=/opt/name/path # Django project directory
SOCKFILE=/opt/name/run/gunicorn.sock # we will communicte using this unix socket
USER=nginx # the user to run as
GROUP=nginx # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=name.settings # which settings file should Django use
DJANGO_WSGI_MODULE=name.wsgi # WSGI module name
Run Code Online (Sandbox Code Playgroud)
lscpu:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 8
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 63
Model name: Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz
Stepping: 2
CPU MHz: 2593.993
BogoMIPS: 5187.98
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 25600K
NUMA node0 CPU(s): 0-7
Run Code Online (Sandbox Code Playgroud)
nginx.conf:
user nginx;
worker_processes 8;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
client_max_body_size 20M;
keepalive_timeout 0;
gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/javascript application/xml;
gzip_disable "MSIE [1-6]\.";
include /etc/nginx/conf.d/*.conf;
Run Code Online (Sandbox Code Playgroud)
这被部署到远程测试服务器。我尝试将NUM_WORKERS
in设置为gunicorn_start
1、3、9 和 17,但无论如何问题仍然存在。
当我关闭manage.py runserver
gunicorn 并使用 .
归档时间: |
|
查看次数: |
1433 次 |
最近记录: |