# Upstream retries with a single server

**URL:** <https://www.ruby-forum.com/t/upstream-retries-with-a-single-server/199410>\
**Category:** NGINX\
**Created:** [November 20, 2010, 5:19pm UTC](https://www.ruby-forum.com/t/upstream-retries-with-a-single-server/199410 "2010-11-20T17:19:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 20, 2010, 5:19pm UTC](https://www.ruby-forum.com/t/upstream-retries-with-a-single-server/199410/1 "2010-11-20T17:19:19Z")

</div>

Hello,  
From the way I understand if there are ‘n’ servers listed as part of  
an upstream block & upstream returns failure (as defined by  
proxy\_next\_upstream), then nginx retries the same request on another  
upstream server and this repeats till every upstream is tried once  
(excluding those that are considered to be down).

If an upstream block is defined with exactly one active server, I see  
that the request gets retried on the same upstream in case of a failure  
upto ‘max\_retries’ number of times. Logically, I’d expect it to try just  
once and then give up if upstream fails to provide a suitable response.

Could someone tell me what is the expected behaviour?

---

<div class="post-metadata">

**Author:** ![Arvind\_Jayaprakash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@Arvind\_Jayaprakash](https://www.ruby-forum.com/u/Arvind_Jayaprakash)\
**Post date:** [November 21, 2010, 12:13am UTC](https://www.ruby-forum.com/t/upstream-retries-with-a-single-server/199410/2 "2010-11-21T00:13:48Z")

</div>

Hello!

On Sat, Nov 20, 2010 at 09:48:15PM +0530, Arvind Jayaprakash wrote:

> Hello,  
> From the way I understand if there are ‘n’ servers listed as part of  
> an upstream block & upstream returns failure (as defined by  
> proxy\_next\_upstream), then nginx retries the same request on another  
> upstream server and this repeats till every upstream is tried once  
> (excluding those that are considered to be down).

Yes.

> If an upstream block is defined with exactly one active server, I see  
> that the request gets retried on the same upstream in case of a failure  
> upto ‘max\_retries’ number of times. Logically, I’d expect it to try just  
> once and then give up if upstream fails to provide a suitable response.

There is no such thing as ‘max\_retries’. As in previous case, all  
(i.e. the only one in this case) upstreams are tried once and then  
appropriate error returned.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Arvind\_Jayaprakash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@Arvind\_Jayaprakash](https://www.ruby-forum.com/u/Arvind_Jayaprakash)\
**Post date:** [November 21, 2010, 2:21pm UTC](https://www.ruby-forum.com/t/upstream-retries-with-a-single-server/199410/3 "2010-11-21T14:21:15Z")

</div>

On Nov 21, Maxim D. wrote:

> Yes.
> 
> > If an upstream block is defined with exactly one active server, I see  
> > that the request gets retried on the same upstream in case of a failure  
> > upto ‘max\_retries’ number of times. Logically, I’d expect it to try just  
> > once and then give up if upstream fails to provide a suitable response.
> 
> There is no such thing as ‘max\_retries’. As in previous case, all  
> (i.e. the only one in this case) upstreams are tried once and then  
> appropriate error returned.

My bad, I meant max\_fails.

I’ve managed to reproduce a problem where the same upstream gets  
retried.

When an upstream block contains one active and one backup server, the  
same request gets retried. Commenting out the backup (line 22 in the  
conf) however seems to exhibit the defined behaviour of try exactly  
once. The access log contains the status for the 2 cases.

I’ve been able to reproduce this on many versions (0.8.[33,34,53])

---

<div class="post-metadata">

**Author:** ![Arvind\_Jayaprakash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@Arvind\_Jayaprakash](https://www.ruby-forum.com/u/Arvind_Jayaprakash)\
**Post date:** [November 21, 2010, 6:47pm UTC](https://www.ruby-forum.com/t/upstream-retries-with-a-single-server/199410/4 "2010-11-21T18:47:47Z")

</div>

Hello!

On Sun, Nov 21, 2010 at 06:49:01PM +0530, Arvind Jayaprakash wrote:

[…]

> When an upstream block contains one active and one backup server, the  
> same request gets retried. Commenting out the backup (line 22 in the  
> conf) however seems to exhibit the defined behaviour of try exactly  
> once. The access log contains the status for the 2 cases.

“backup” is known to have this problem, yes.

Maxim D.
