I have a Rails application (v3.2.13, Ruby 2.0.0) running on nginx + Unicorn (Ubuntu 12.04). Everything works well, unless the admin user downloads (thousands) of users through a CVS file. The problem is that I set the timeout to 30 seconds and the import process takes much longer. So, after 30 seconds, I get the nginx 502 Bad Gateway page (killed working Unicorn).
The obvious solution is to increase the timeout, but I do not want this because it will cause other problems (I think), because this is not typical behavior.
Is there any way to deal with such problems?
Thank you very much in advance.
PS: Maybe this is a solution to change the code. If so, I want the user to not execute another request.
Some ideas (I donβt know if this is possible):
- Set up a worker dedicated to this request.
- Send Work in progress to Unicorn to avoid killing.
Nginx-app.conf
upstream xxx { server unix:/tmp/xxx.socket fail_timeout=0; } server { listen 80; ... location / { proxy_pass http://xxx; proxy_redirect off; ... proxy_connect_timeout 360; proxy_send_timeout 360; proxy_read_timeout 360; } }
unicorn.rb
worker_processes 2 listen "/tmp/xxx.socket" timeout 30 pid "/tmp/unicorn.xxx.pid"
ruby-on-rails timeout nginx unicorn
cortex
source share