![](/img/trans.png)
[英]Issues with nginx reverse proxy to an app server running nginx+django
[英]How to change uwsgi(nginx+django) app reload mode to decrease reload/wait latency for first request
嘗試減少第一次請求的重新加載/等待時間時遇到問題。
我使用的是nginx 1.7,uwsgi 2.0.4,django 1.6。 一開始,我發現第一個請求非常慢,並且從日志中發現,這是因為為第一個請求加載了應用程序。 因此,我在Google上搜索了很多,並嘗試更改uwsgi重新加載模式。
我想使用惰性應用程序模式來減少延遲。 但是,總是會遇到錯誤。
uwsgi配置:
<uwsgi>
<socket>/var/run/uwsgi.socket</socket>
<listen>100</listen>
<master>true</master>
<vhost>true</vhost>
<no-site>true</no-site>
<pidfile>/usr/local/nginx/uwsgi.pid</pidfile>
<processes>8</processes>
<profiler>true</profiler>
<memory-report>true</memory-report>
<enable-threads>true</enable-threads>
<logdate>true</logdate>
<lazy-apps>true</lazy-apps>
<touch-chain-reload>true</touch-chain-reload>
<limit-as>6048</limit-as>
<daemonize>/home/django.log</daemonize>
</uwsgi>
這是nginx的配置:
server {
listen 80;
server_name xxx.com;
location / {
uwsgi_pass unix:///var/run/uwsgi.socket;
include uwsgi_params;
uwsgi_param UWSGI_CHDIR /home/test;
uwsgi_param UWSGI_SCRIPT wsgi;
access_log off;
}
location /static/ {
root /home/test/;
access_log off;
log_not_found off;
autoindex on;
}
}
但似乎沒有任何變化,請在此處登錄:
[root@localhost ~]# tail -f /home/django.log
Wed Sep 2 11:45:55 2015 - spawned uWSGI worker 7 (pid: 23818, cores: 1)
Wed Sep 2 11:45:55 2015 - spawned uWSGI worker 8 (pid: 23819, cores: 1)
Wed Sep 2 11:45:55 2015 - *** no app loaded. going in full dynamic mode ***
Wed Sep 2 11:45:55 2015 - *** no app loaded. going in full dynamic mode ***
Wed Sep 2 11:45:55 2015 - *** no app loaded. going in full dynamic mode ***
Wed Sep 2 11:45:55 2015 - *** no app loaded. going in full dynamic mode ***
Wed Sep 2 11:45:55 2015 - *** no app loaded. going in full dynamic mode ***
Wed Sep 2 11:45:55 2015 - *** no app loaded. going in full dynamic mode ***
Wed Sep 2 11:45:55 2015 - *** no app loaded. going in full dynamic mode ***
Wed Sep 2 11:45:55 2015 - *** no app loaded. going in full dynamic mode ***
仍然只有在第一個請求到來時應用程序才會加載,並且延遲增加到將近7秒。 我的配置錯誤嗎? 還是不應該使用惰性應用程序? 如果是這樣,還有什么其他方式適合我的情況?
謝謝。 衛斯理
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.