我正在为我的Django项目使用Nginx-uWSGI组合,但是当我将它与Nginx-Apache-modwsgi组合进行比较时,性能低于标准。显然,uwsgi花了大约3-5秒的时间来响应请求,服务器最多应该在300-400毫秒左右。
当我运行分析时,我意识到大部分时间都花在uWSGI Handler的response.render
函数中。以下是分析结果 -
我无法弄清楚为什么method poll
占用的时间超过90%,即使服务器上只有一个请求。
这是我的uwsgi配置
[uwsgi]
uid = www-data
gid = www-data
listen = 10000
socket-timeout = 60
socket-send-timeout = 60
socket-write-timeout = 60
set-placeholder = username=sysadmin
set-placeholder = project_directory=/home/sysadmin/builds/deploy_dir/qa_shine
set-placeholder = ruby_shims_path=/home/sysadmin/.rbenv/shims
socket = /run/%n.sock
chmod-socket = 666
chdir = %(project_directory)
pidfile = /run/%n.pid
wsgi-file = deploy/uwsgi.py
master = true
processes = 1
threads = 1
harakiri = 160
virtualenv = /home/%(username)/Envs/candidate/
stats = 127.0.0.1:9191
vacuum = true
die-on-term = true
daemonize = /var/log/uwsgi/%n.log
env = LANG=en_US.UTF-8
auto-procname = true
env = PATH=%(ruby_shims_path):$(PATH)
env = RUBYPATH=%(ruby_shims_path)/ruby
rbrequire = rubygems
我的nginx上游配置
location / {
uwsgi_pass django;
include uwsgi_params;
proxy_buffering off;
proxy_buffers 128 128k;
proxy_buffer_size 128k;
proxy_temp_path /run/ 1 2;
uwsgi_read_timeout 60;
uwsgi_send_timeout 60;
uwsgi_connect_timeout 60;
send_timeout 60;
}
# basic conf
events {
worker_connections 8192;
use epoll;
multi_accept on;
}
我现在完全失去了,任何帮助都会受到赞赏。
答案 0 :(得分:0)
最后我解决了这个问题。显然问题是我已禁用离线压缩,但我使用的sass
文件需要在运行时转换为css
。事实证明这导致了很多IO。当我启用离线压缩时,响应时间回落到200毫秒。