uWSGI-Django spending too much time on poll method
<p>I am using Nginx-uWSGI combination for my Django project, but the performance is sub-par when I compare it with Nginx-Apache-modwsgi combination. Apparently uwsgi was taking about 3-5 seconds to provide response for requests which should be server in about 300-400ms at most.</p>

<p>When I ran profiling, I realized most of the time is being spend in <code>response.render</code> function in uWSGI Handler. Here are the profiling results -</p>

<p><a href="http://i.stack.imgur.com/UvHV6.png" rel="nofollow"><img src="http://i.stack.imgur.com/UvHV6.png" alt="Profiling result"></a></p>

<p>I am unable to figure out why <code>method poll</code> is consuming more than 90% of the time, even when there is just one request on the server.</p>

<p>Here is my uwsgi configuration</p>

<pre><code>[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
</code></pre>

<p>My nginx upstream configuration</p>

<pre><code>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;
}
</code></pre>

<p>I'm completely lost right now, any help would be appreciated.</p>

<p>Finally I fixed the issue. Apparently the issue was that I'd offline compression disabled, but I was using <code>sass</code> files which needed to be transformed into <code>css</code> at runtime. Turns out that was causing a lot of IO. When I enabled offline compression, response time fell back to 200ms.</p>

python django sockets nginx uwsgi