Increase varnish timeout for a specific path

I have a set of scripts on the /admin path that can take a while to execute, and cause Varnish to hit the timeout limit. Is there a way to increase the timeouts for a particular path rather than for an entire backend?


Solution 1:

You may try to add one more backend with same host, but different timeouts

And use it for your urls with req.backend

backend default {
.host = "127.0.0.1";
.port = "81";
}

backend admin {
.host = "127.0.0.1";
.port = "81";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
}

sub vcl_recv {
...
if (req.url ~ "^/admin")
{
set req.backend = admin;
}
..
}

Solution 2:

Just recently ran into something like this ..

We added the following in the backends (make sure NOT TO PUT it in the .probe { } sub-declaration [just a small error that caused a hint of confusion for us for a short time ;]):

.connect_timeout = 60s;
.first_byte_timeout = 120s;
.between_bytes_timeout = 60s;

You can read more about them with 'man vcl'.

Hope this helps!

Solution 3:

Use vcl_backend_fetch and set the timeout there:

sub vcl_backend_fetch { if (bereq.method == "POST" && bereq.url == "/slow") { set bereq.first_byte_timeout = 300s; } }