health check varnish

Johan Hendriks joh.hendriks at gmail.com
Fri Dec 31 12:41:05 UTC 2021


On 30/12/2021 10:17, Dridi Boukelmoune wrote:
> On Thu, Dec 30, 2021 at 8:17 AM Johan Hendriks <joh.hendriks at gmail.com> wrote:
>> Hello all, first off all, thanks for a year full of varnish happiness
>> like the developers page and the parallel ESI for the varnish-cache edition.
>>
>> We use the following in the vcl for our varnish health check from our
>> haproxy loadbalancers
>>
>> if (req.url == "/varnish_status") {
>>           if (!std.healthy(req.backend_hint)) {
>>               return (synth(500, "Varnish: unhealthy backend."));
>>           }
>>           else {
>>               return (synth(200, "Varnish: All good!"));
>>           }
>>       }
>>
>> And this works fine if we run varnish on the webserver itself with only
>> one backend.
>> But if we use the director with multiple backends we get an 500 error if
>> one of the backend servers is offline even if the director itself has
>> enough servers left and still is marked ad healthy.
>>
>> Is there a way to check if the director itself is down?
>>
>> like
>> Backend name      Admin    Probe    Health     Last change
>> boot.web01        probe    5/5      healthy    Mon, 27 Dec 2021 08:42:58 GMT
>> boot.web02        probe    5/5      healthy    Mon, 27 Dec 2021 08:42:58 GMT
>> boot.web03        probe    5/5      healthy    Mon, 27 Dec 2021 08:42:58 GMT
>> boot.webcluster   probe    2/2      healthy    Mon, 27 Dec 2021 08:42:58 GMT
>>
>> return a 200 as all is good
>>
>> boot.web01        probe    2/5      sick       Wed, 29 Dec 2021 18:33:41 GMT
>> boot.web02        probe    4/5      healthy    Wed, 29 Dec 2021 18:33:41 GMT
>> boot.web03        probe    4/5      healthy    Wed, 29 Dec 2021 18:33:41 GMT
>> boot.webcluster   probe    1/2      healthy    Wed, 29 Dec 2021 18:33:41 GMT
>>
>> still return a 200 as we still have a healthy webcluster backend.
>>
>> Backend name      Admin    Probe    Health    Last change
>> boot.web01        probe    2/5      sick      Wed, 29 Dec 2021 18:34:40 GMT
>> boot.web02        probe    2/5      sick      Wed, 29 Dec 2021 18:34:40 GMT
>> boot.web02        probe    2/5      sick      Wed, 29 Dec 2021 18:34:40 GMT
>> boot.webcluster   probe    0/2      sick      Wed, 29 Dec 2021 18:34:40 GMT
>>
>> return the 500 error code as our webcluster backend is down.
>>
>> So can we just get the health status of webcluster in this case?
> If you assign webcluster.backend() to req.backend_hint before
> performing the health check it should work fine.
>
> Dridi

Thank you, that did the trick. I knew it had to be something simple that 
i overlooked.
Have a wonderful 2022 all.

regards
Johan



More information about the varnish-misc mailing list