How does Nginx know tomcat is running or not?

Sunday, May 4, 2014

I use Nginx as load balancer with tomcat 7. There are two tomcat in different machine, if I turn tomcat1 off and refresh the page, it will spend 1 minute to judge if tomcat1 is running, then redirect the request to tomcat2. If I turn tomcat2 off and refresh the page, the first time it will visit tomcat1, the second time it will visit tomcat2, and spend 1 minute to judge if tomcat2 is running, then redirect the request to tomcat1. Here is my nginx.conf



upstream localhost{
server 10.6.28.56:7171;
server 10.6.28.57:7171;
}

location / {
root html;
index index.html index.htm;
proxy_pass http://localhost;
}


Here is error.log 2014/05/04 14:41:27 [error] 4180#4656: *543 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 192.168.9.48, server: localhost, request: "GET /t1/index.jsp HTTP/1.1", upstream: "http://ift.tt/1iQWIEO", host: "10.6.28.56:7080"


1 minute are too long, how does nginx judge more quickly and choose the alive tomcat?







http://ift.tt/1fH36nS