update1: sub probe_resp - VIP RFC
Nils Goroll
slink at schokola.de
Wed Apr 12 07:35:18 CEST 2017
first update based on feedback from Dridi
Hi,
https://github.com/varnishcache/varnish-cache/wiki/Varnish-Improvement-Proposals :
"The VIP procedure starts with a discussions on varnish-dev"
I had skipped this bit for previous suggestions, but this time I want to get it
right. I'd like to propose the following:
# Synopsis
Add support for calling vcl subs on the response of backend probes.
# Why?
Add a way to manipulate backends not just on the basis of a binary health check
result, but optionally also on the basis of other information returned by the
backend with the probe response.
One example would be to dynamically change the weight of backends based on a
load metric returned with the probe response, which will also require
vmod_directors to support changing the weight dynamically.
# How?
* Add VCC support to register VCL subs with probes
* Add a default vcl_probe_response sub to the builtin.vcl which implements the
current behavior. Probes without an explicit response sub definition will
use vcl_probe_response
* in probe response vcl context, make the following objects available
- analogous to beresp
- beresp.backend
- beresp.http.*
- beresp.proto
- beresp.status
- beresp.reason
- later?
- beresp.body
By design, all access should be read-only, but we might want to
have all but .backend writable for practical reasons (writes
having no effect other than being visible in the sub probe_resp)
- probe.* attributes of the probe (read-only)
- probe.name
- probe.expected_response
- probe.timeout
- probe.interval
- probe.initial
- probe.window
- probe.threshold
* a probe response vcl sub may return with the following
ok
fail
* The default vcl_probe_response:
sub vcl_probe_response {
if (beresp.proto ~ "^HTTP/\d+\.\d+$" &&
beresp.status == probe.expected_response) {
return (fail);
}
return (ok);
}
this matches the existing implementation, we might want to change
the first condition to beresp.proto ~ "^HTTP/1\.[01]$" once this
is in place
* Toy example for the use case mentioned above (needs more changes)
sub probe_weight {
if (beresp.http.X-Load ~ "^\d+\.\d+$") {
my_rr.set_weight(beresp.backend,
1 / std.real(req.http.X-Load, 1.0));
}
}
More information about the varnish-dev
mailing list