title: Nginx upstream configuration
body: <p>I am trying to configure nginx with upstream.</p>
  
  <p>We have 3 machines where we run application server and proxy passing all requests from nginx to application serves.</p>
  
  <p>I used following configuration in nginx:</p>
  
  <pre><code>upstream appcluster {
   server host1.example.com:8080 max_fails=2 fail_timeout=300s;
   server host2.example.com:8080 max_fails=2 fail_timeout=300s;
  }
  </code></pre>
  
  <p>Now issue is if the request comes to nginx when one server is down due to unknown reasons it's waiting for a long time getting response or sometimes its getting connection timeout.</p>
  
  <p>Can someone suggest me the right configuration to get a response from the appcluster without latency or connection timeout whenever a server won't respond?</p>