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?
Asked
Active
Viewed 5,879 times
4 Answers
10
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;
}
..
}

ghloogh
- 1,049
- 5
- 9
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!

Bryan
- 21
- 1
1
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;
}
}

Berend de Boer
- 131
- 3
0
You can use pipe for long requests
if (req.url ~ "^/admin/long_request" || req.url ~ "^/upload")
{
return (pipe);
}
# just add the Connection: close header
sub vcl_pipe {
set bereq.http.connection = "close";
}

Moshe L
- 113
- 3