How to adjust priority for both backend healthy

Hamidreza Hosseini hrhosseini at hotmail.com
Thu Feb 18 15:10:09 UTC 2021


How can I probe a backend varnish? for example I have 2 layer varnish disk layer and ram layer and ram layer want to check the health of layer 2, How can I do this? I've done something but I have error:

sudo varnishadm backend.list -p
Backend name                   Admin      Probe                Last updated
boot.varnish_1                 probe      Sick                0/5
  Current states  good:  0 threshold:  3 window:  5
  Average response time of good probes: 0.000000
  Oldest ================================================== Newest
  ---------------------------------------------------------------- Happy

sudo varnishlog -g raw -i Backend_health
0 Backend_health - boot.varnish_1 Still sick -------- 0 3 5 0.000000 0.000000 Open error 111 (Connection refused)

my config:
probe myprobe {
    .request =
      "HEAD / HTTP/1.1"
      "Connection: close"
      "User-Agent: Varnish Health Probe";
    .timeout = 1s;
    .interval = 5s;
    .window = 5;
    .threshold = 3;
}

________________________________
From: Hamidreza Hosseini
Sent: Thursday, February 18, 2021 5:31 AM
To: varnish-misc at varnish-cache.org <varnish-misc at varnish-cache.org>
Subject: How to adjust priority for both backend healthy

I have two backend that both of them are healthy and I use fallback for them and I want to say all request should goes to backend1 and if backend1 become unhealthy all requests should go to backend2 but backend1 has higher priority and when backend1 become healthy, all  requests should go to backend1,
How can I define priority?
my config:

```
vcl 4.1;

import directors;

probe myprobe {
    .request =
      "HEAD / HTTP/1.1"
      "Connection: close"
      "User-Agent: Varnish Health Probe";
    .timeout = 1s;
    .interval = 5s;
    .window = 5;
    .threshold = 3;
}

backend backend1 { .host = "backend1"; .port = "8080"; .probe = myprobe; }

backend backend2 { .host = "backend2"; .port = "8080"; .probe = myprobe; }
backend backend3 { .host = "backend3"; .port = "8080"; .probe = myprobe; }


sub vcl_init {

    new backend2_cluster = directors.round_robin();
    backend2_cluster.add_backend(backend2);
    backend3_cluster.add_backend(backend3);


    new backend_cluster_fb = directors.fallback();
    backend1_fb.add_backend(backend1);
    backend2_cluster_fb.add_backend(backend2_cluster.backend());
}

sub vcl_recv {
    set req.backend_hint = backend_cluster_fb.backend();

}

```

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20210218/e0a6975d/attachment.html>


More information about the varnish-misc mailing list