Forum: NGINX Problem request_timeout not working with proxy_next_upstream on proxy_connect_timeout but proxy_read

Posted by yvlasov (Guest)
on 2013-03-06 11:28
(Received via mailing list)
Hello
In our setup we have an NGNX  as front-end and several back-end.
The problem is our load profile, we have a lot of simple and fast http
requests, and very few but very heavy in terms of time and BE cpu 
requests.

So my idea is to use proxy_next_upstream for simple request as usual and 
it
works perfectly.
And for heavy requests based on URL I want to passthrough it to BE with
lowest CPU load by specifying small proxy_connect_timeout and using
proxy_next_upstream timeout.
But in case of all system overload with heavy requests i don't want them 
to
travel through all BEs because of proxy_read_timeout is about 1 minute.
I was hoping to set a request_timeout to the same value as
proxy_read_timeout and from my point of view this should prevent heavy
requests to travel all upstreams based on proxy_read_timeout, but they 
do.

I ve found a similar topic but the proposition was to make two new 
options
to proxy_next_upstream such as timeout_tcp timeout_http or something
similar.

Thanks for your future advices and comments.

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,236982,236982#msg-236982
Posted by yvlasov (Guest)
on 2013-03-06 11:45
(Received via mailing list)
For beter understanding here is my config sniper

upstream super_upstream {
        keepalive 128;
        server be1 max_fails=45 fail_timeout=3s;
        server be2 max_fails=45 fail_timeout=3s;
        server be3 max_fails=45 fail_timeout=3s;
  }

server {
server_name pytn.ru;
location ^~ /simple_requests {
 proxy_read_timeout 2s;
 proxy_send_timeout 2s;
 proxy_connect_timeout 10ms;
 proxy_next_upstream     error timeout invalid_header http_500 http_502
http_503 http_504;
 proxy_pass http://super_upstream;
}

location ^~ /very_heavy_requests {
 send_timeout 60s;
 proxy_read_timeout 60s;
 proxy_send_timeout 60s;
 proxy_connect_timeout 5ms;
 proxy_next_upstream timeout;
 proxy_pass http://super_upstream;
}

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,236982,236983#msg-236983
Posted by Maxim Dounin (Guest)
on 2013-03-06 13:40
(Received via mailing list)
Hello!

On Wed, Mar 06, 2013 at 05:28:12AM -0500, yvlasov wrote:

> But in case of all system overload with heavy requests i don't want them to
> travel through all BEs because of proxy_read_timeout is about 1 minute.
> I was hoping to set a request_timeout to the same value as
> proxy_read_timeout and from my point of view this should prevent heavy
> requests to travel all upstreams based on proxy_read_timeout, but they do.
>
> I ve found a similar topic but the proposition was to make two new options
> to proxy_next_upstream such as timeout_tcp timeout_http or something
> similar.
>
> Thanks for your future advices and comments.

I think that some aggregate upstream timeout, which will prevent
switch to a next upstream server if passed, whould be better
solution to this problem.

--
Maxim Dounin
http://nginx.org/en/donation.html
Posted by yvlasov (Guest)
on 2013-03-07 14:47
(Received via mailing list)
Good idea but we have to keep in mind it should depend on location 
context.
THX

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,236982,237064#msg-237064
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.