# Proxy\_next\_upstream, only "connect" timeout?, try 2

**URL:** <https://www.ruby-forum.com/t/proxy-next-upstream-only-connect-timeout-try-2/220654>\
**Category:** NGINX\
**Created:** [June 15, 2012, 9:37am UTC](https://www.ruby-forum.com/t/proxy-next-upstream-only-connect-timeout-try-2/220654 "2012-06-15T09:37:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 15, 2012, 9:37am UTC](https://www.ruby-forum.com/t/proxy-next-upstream-only-connect-timeout-try-2/220654/1 "2012-06-15T09:37:14Z")

</div>

regarding my original email:  
[http://article.gmane.org/gmane.comp.web.nginx.english/34175](http://article.gmane.org/gmane.comp.web.nginx.english/34175)

i assume the silence means there is no such way.

would it be hard to implement it? i can try it, but i’d need to know  
if it’s at least possible or not,  
if there are the necessary ‘hooks’ in place and such…

thanks,  
gabor

---

<div class="post-metadata">

**Author:** ![SSGSSbor\_FarkasSS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a88e57/32.png) [@SSGSSbor\_FarkasSS\_S](https://www.ruby-forum.com/u/SSGSSbor_FarkasSS_S)\
**Post date:** [June 15, 2012, 10:03am UTC](https://www.ruby-forum.com/t/proxy-next-upstream-only-connect-timeout-try-2/220654/2 "2012-06-15T10:03:33Z")

</div>

Hello!

On Fri, Jun 15, 2012 at 09:36:39AM +0200, Gábor Farkas wrote:

> regarding my original email:  
> [http://article.gmane.org/gmane.comp.web.nginx.english/34175](http://article.gmane.org/gmane.comp.web.nginx.english/34175)
> 
> i assume the silence means there is no such way.
> 
> would it be hard to implement it? i can try it, but i’d need to know  
> if it’s at least possible or not,  
> if there are the necessary ‘hooks’ in place and such…

We probably need something more generic, i.e. some distinction  
between idempotent and non-idempotent cases in  
proxy\_next\_upstream. This should allow to retry GET/HEAD at any  
point, while keeping POSTs safe.

Maxim D.

---

<div class="post-metadata">

**Author:** ![SSGSSbor\_FarkasSS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a88e57/32.png) [@SSGSSbor\_FarkasSS\_S](https://www.ruby-forum.com/u/SSGSSbor_FarkasSS_S)\
**Post date:** [June 15, 2012, 10:08am UTC](https://www.ruby-forum.com/t/proxy-next-upstream-only-connect-timeout-try-2/220654/3 "2012-06-15T10:08:14Z")

</div>

On Fri, Jun 15, 2012 at 10:02 AM, Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > if it’s at least possible or not,  
> > if there are the necessary ‘hooks’ in place and such…
> 
> We probably need something more generic, i.e. some distinction  
> between idempotent and non-idempotent cases in  
> proxy\_next\_upstream. This should allow to retry GET/HEAD at any  
> point, while keeping POSTs safe.

i agree, but i would still prefer to be able to specify the  
on-connect-timeout-only too,  
there are some cases where i do not want to repeat even a GET request,  
and generally it is a safer bet for me to not-repeat anything that  
already ‘reached’  
the upstream.

you see, my specific problem is that i have multiple upstreams, and i  
want nginx  
to go to the next upstream when an upstream’s socket-backlog is full.  
and currently  
i am unable to do this…

gabor

---

<div class="post-metadata">

**Author:** ![SSGSSbor\_FarkasSS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a88e57/32.png) [@SSGSSbor\_FarkasSS\_S](https://www.ruby-forum.com/u/SSGSSbor_FarkasSS_S)\
**Post date:** [November 26, 2012, 1:17pm UTC](https://www.ruby-forum.com/t/proxy-next-upstream-only-connect-timeout-try-2/220654/4 "2012-11-26T13:17:08Z")

</div>

I’m interested on the subject.  
On my current set up, I’m using the timeout option to make sure the  
request  
is passed to the next upstream if the first server is down.  
If the request is hanging, it’s possible the request coming in is a bad  
request, which could slow down the full cluster.  
I would like to go to the next upstream only on connection timeout.  
I wonder if you could provide two additional options, “read\_timeout” and  
“connect\_timeout”, leaving “timeout” unchanged.

Posted at Nginx Forum:

> **[Re: proxy\_next\_upstream, only "connect" timeout?, try 2](https://forum.nginx.org/read.php?2,227552,233222#msg-233222)**
>
> regarding my original email: http://article.gmane.org/gmane.comp.web.nginx.english/34175 i assume the silence means there is no such way. would it be hard to implement it? i can try it, but i'd need to know if it's at least possible or not, if there...

---

<div class="post-metadata">

**Author:** ![SSGSSbor\_FarkasSS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a88e57/32.png) [@SSGSSbor\_FarkasSS\_S](https://www.ruby-forum.com/u/SSGSSbor_FarkasSS_S)\
**Post date:** [June 15, 2012, 12:30pm UTC](https://www.ruby-forum.com/t/proxy-next-upstream-only-connect-timeout-try-2/220654/5 "2012-06-15T12:30:14Z")

</div>

Hello!

On Fri, Jun 15, 2012 at 10:07:35AM +0200, Gábor Farkas wrote:

> > > would it be hard to implement it? i can try it, but i’d need to know  
> > > there are some cases where i do not want to repeat even a GET request,  
> > > and generally it is a safer bet for me to not-repeat anything that  
> > > already ‘reached’  
> > > the upstream.

Sure, this needs some configuration for a things which should be  
considered idempotent, as http methods are often misused.

> you see, my specific problem is that i have multiple upstreams, and i want nginx  
> to go to the next upstream when an upstream’s socket-backlog is full.  
> and currently  
> i am unable to do this…

Practical solution for the specific problem of full listen queue  
is to instruct your OS to return RST in this case (this  
is usually the default behaviour, but Linux seems to be an  
exception), and use “proxy\_next\_upstream error”. You may also try  
small proxy\_connect\_timeout vs. long proxy\_read\_timeout and  
proxy\_send\_timeout.

This still has a theoretical problem though, as error might occur  
for some reason during sending request to an upstream, and this  
will trigger use of next upstream server.

Maxim D.
