Updating the backend definitions in VCL at runtime
Hi,
We’ve got a system where some of the requests take a little longer than others, and we need to increase the timeout on them.
Rather than creating a new origin definition, I’m wondering if it is possible to update the origin on the fly in the VCL?
I’ve seen the other thread at Can I set set req.backend.host dynamically - which indicates if this is possible. However, in that thread mpapper is looking to update the item on every request.
If I update the backend (req.backend) rather than F_origin, does this override the setting for future requests?
The VCL I’m looking at for this is as follows - though I don’t seem to be allowed to update the timeout as I want to in the code below.
## Use SSL backend for SSL requests
## Use the _post variants for POST requests and close connection after each request
if (req.request == "POST") {
set req.http.Connection = "close";
if (req.http.Fastly-SSL) {
set req.backend = F_origin_ssl_post;
} else {
set req.backend = F_origin_post;
}
} else {
if (req.http.Fastly-SSL) {
set req.backend = F_origin_ssl;
} else {
set req.backend = F_origin;
}
}
## Handle the special case of login
if ( (req.request == "POST") && (req.url == "/AjaxCustomLogon") ) {
set req.backend.first_byte_timeout = 60s;
set req.backend.between_bytes_timeout = 60s;
The only other option I can see is another backend definition, which I’d rather not have to do.
Many thanks,
Will.
-
Hi Doc,
I am interested in doing what Will described above as well. Changing these backend timeouts at runtime would be useful for me, and simplify something I'm already doing in the VCL.
I tried setting
req.backend.first_byte_timeout
and was shown a validation error when uploading my VCL.Unknown variable 'req.backend.first_byte_timeout' At: (input Line 1782 Pos 17) set req.backend.first_byte_timeout = 120s; ----------------##############################-------- Running VCC-compiler failed
Will this be something supported in the future? Thanks!
-
I got the same issue when I tied too (as I stated as "though I don't seem to be allowed to update the timeout as I want to in the code below").
Frustrating, as allowing this would be an elegant solution. We know which requests are likely to take longer than 'normal' requests. I'd rather not have to create a new backend (we have enough of these anyway!).
@Doc - any change of an enhancement to allow this to be set?
-
Oh, crud, I do apologize. I was just going off of code that I knew was there in our Varnish, I never actually verified what the VCL variables were.
Instead of
req.backend.*
it's actuallybereq.backend.*
and only invcl_miss
andvcl_pass
.The three that are available are:
bereq.connect_timeout bereq.first_byte_timeout bereq.between_bytes_timeout
Please sign in to leave a comment.
Comments
7 comments