Varnish backend timeout doesn't work with keep alive backend

JackDrogon jack.xsuperman at gmail.com
Wed Dec 28 11:45:51 CET 2016


OK.
 I run a go server, such as:

func handler(res http.ResponseWriter, req *http.Request) {
        atomic.AddUint32(&times, 1)
        number := rand.Intn(100)
        fmt.Printf("Random number: %d.\n", number)
        t := atomic.LoadUint32(&times)
        if t%4 == 1 {
                time.Sleep(7 * time.Second)
        }
        fmt.Fprintf(res, "Random number: %d.\n", number)
        fmt.Println("=========================")
}


I use this as varnish backend, and setting hash_always_miss
so I curl 127.0.0.1:8000 for 5 times.

curl 127.0.0.1:8000  0.00s user 0.00s system 0% cpu 2 total
curl 127.0.0.1:8000  0.00s user 0.00s system 77% cpu 0.005 total
curl 127.0.0.1:8000  0.00s user 0.00s system 66% cpu 0.005 total
curl 127.0.0.1:8000  0.00s user 0.00s system 68% cpu 0.004 total
curl 127.0.0.1:8000  0.00s user 0.00s system 0% cpu 7.005 total 

I think the fifth requet's time usage is 2s, but It's 7s. How can I set varnish to make it be 2s

On 28 December 2016 at 18:19:21, Boukelmoune Dridi (dridi at varni.sh) wrote:

On Wed, Dec 28, 2016 at 10:24 AM, Andreas Plesner <apj at mutt.dk> wrote:  
> On Wed, Dec 28, 2016 at 05:12:54PM +0800, JackDrogon wrote:  
>  
>> I set varnish backend that:  
>> backend default { .host = "127.0.0.1"; .port = "4567"; .connect_timeout  
>> = 1s; .first_byte_timeout = 2s; .between_bytes_timeout = 1s; }  
>> The first timeout is right, but if the prev connection is right,  
>> varnish use keepalive to deal with the next connection with same url  
>> and the timeout conf doesn't wok.  
>  
> Please elaborate. Describe the situation that doesn't work as you expect, and what you would expect to happen.  

Possibly a known problem [1] for first_byte_timeout, apparently still  
an open issue.  

Dridi  

[1] https://github.com/varnishcache/varnish-cache/issues/1772  

_______________________________________________  
varnish-misc mailing list  
varnish-misc at varnish-cache.org  
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20161228/c676364d/attachment.html>


More information about the varnish-misc mailing list