我有一個Rails應用程序與nginx /獨角獸有一個特定的請求,可能需要2-3分鐘,因爲它是生成幾個PDF並將它們添加到一個zip文件和使用send_data允許客戶一次下載多個報告。Nginx上游超時的麒麟長請求
本來我的獨角獸工人在30多歲後就遇難了,所以我在unicorn.rb文件中增加了我的超時時間。現在請求在60秒之後而不是30秒之後出現504錯誤。所以我的獨角獸工人正在被殺,但nginx已經超時。
下面是我的Nginx的error_log錯誤消息:
upstream timed out (110: Connection timed out) while reading response header from upstream
我已經試過所有增加nginx的超時設置,使意義,但service nginx restart
後的請求仍timeing出來。
這裏是我的nginx.conf和/默認啓用
網站,/***nginx.conf***/
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 300s;
client_header_timeout 300s;
client_body_timeout 300s;
send_timeout 300s;
types_hash_max_size 2048;
}
/***sites-enabled/default***/
upstream app {
unix:[PATH]/unicorn.sock fail_timeout=120s;
}
server {
listen 80;
root [PATH];
server_name www.[URL].com [URL].com;
proxy_read_timeout 600s;
try_files $uri/index.html $uri @app;
access_log /var/log/nginx/APP_access.log combined;
error_log /var/log/nginx/APP_error.log;
location @app {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app;
proxy_read_timeout 600s;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 75;
}
誰能告訴我,爲什麼nginx的60秒後仍超時?
你確定你不需要再增加獨角獸超時 - 這個錯誤信息似乎表明'上游'超時有問題 – house9
真的,你應該使用後臺作業來處理超過30秒的事情 - 你可能想看看延遲的工作:https://github.com/collectiveidea/delayed_job – house9
@ house9,是的,我忘了提及。後臺工作是必要的,但它不在MVP中。當獨角獸超時是問題時,錯誤消息是在獨角獸錯誤日誌中,它表示類似「超時(31s> 30s)」,現在錯誤是上面的錯誤,它在ngoni日誌中。此外,我將獨角獸超時設置爲超過60秒。 –