提问人:demluckycharms 提问时间:9/12/2018 更新时间:9/12/2018 访问量:2971
Gunicorn 在某些页面上将 CPU 飙升至 100%......杀戮性能
Gunicorn spiking CPU to 100% on certain pages...killing performance
问:
我有一个通过 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
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
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;
这将部署到远程测试服务器。我尝试将 in 设置为 1、3、9 和 17,但无论如何问题仍然存在。NUM_WORKERS
gunicorn_start
当我关闭 gunicorn 并在机器上本地运行它时,问题消失了,速度也很好,所以我知道问题出在 Nginx 或 Gunicorn 上。manage.py runserver
答: 暂无答案
评论