Hold requests long enough for me to restart upstream?
Manlio Perillo
manlio_perillo at libero.it
Sun Mar 22 02:39:59 MSK 2009
Rt Ibmer ha scritto:
> I use nginx 0.6.31 with proxy_pass to front end requests to a servlet running in Jetty (the upstream).
>
> Sometimes I need to update a jar on the upstream, which requires restarting jetty to take effect.
>
> I am looking for a way to tell nginx that if it gets a connection failure at the upstream (which is what happens when jetty is in the process of restarting since nothing is listening on that port during the restart) that it should give it say 20 seconds before erroring out the request back to the browser.
>
> Certainly this will back up the processing a bit, but it should be very short as it only takes Jetty about 10 seconds to restart and start listening again on its port. During slow periods we are only getting 2-5 requests per second so there should be plenty of resources for nginx to queue up these requests while it waits for Jetty.
>
> Can someone please tell me what settings I should use so that nginx will wait up to 20 seconds for the upstream to restart so that it doesn't return an error to the browser?
>
This should be quite easy if you add another custom "backup" server.
In Nginx config (not tested):
upstream backend {
server backend1.example.com;
server 127.0.0.1:8080 backup;
}
In the custom backup server, all you need to do is to pause every
request for 20 seconds; after this just do a redirect to the same
request URI.
> [...]
P.S.: your mail user agent does not wrap long lines
Regards Manlio
More information about the nginx
mailing list