6

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?

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;
}
..
}
1

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!

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; } }

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";
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.