proxy timeouts as milliseconds?

Maxim Dounin mdounin at mdounin.ru
Wed Dec 9 14:32:01 MSK 2009


Hello!

On Wed, Dec 09, 2009 at 05:54:50AM -0500, dobe wrote:

> hi all
> 
> does anybody know if it is possible to set millisecond values for:
> 
>         proxy_connect_timeout    
>         proxy_send_timeout         
>         proxy_read_timeout     
> 
> 
> my usecase is to have fallbacks for requests that take longer than about 200 milliseconds, especially for use with SSI

Try something like this:

    proxy_connect_timeout  200ms;
    proxy_send_timeout     200ms;
    proxy_read_timeout     200ms;

Note well: such small values may produce a somewhat unexpected results, since 
nginx uses lazy timer updating.  Quoting src/event/ngx_event_timer.h:

: #define NGX_TIMER_LAZY_DELAY  300

...

: static ngx_inline void
: ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer)
: {

...

:         /*
:          * Use a previous timer value if difference between it and a new
:          * value is less than NGX_TIMER_LAZY_DELAY milliseconds: this allows
:          * to minimize the rbtree operations for fast connections.
:          */

As a result, in the above configuration it is likely 
that response time will be limited by 200ms in total.  And big 
responses will eventually timeout even if no real pauses happen 
in connection.

Depending on your needs you may consider lowering 
NGX_TIMER_LAZY_DELAY.

Maxim Dounin



More information about the nginx mailing list