Mailing List Archive

solution for Active/Passive Backend
Hi,
I want to have 2 or 3 backends in the Varnish config file but just one of them workes as an active backend and whenever my active backend failed , the second backend become active and respond the requests. (In other hand, I dont want to have two backend for responding clients and just one of them works at the same time, and it check the health status of my active backend , whenever it is was unhealthy , varnish switch to the second or third backend.)
Best Regards.
Re: solution for Active/Passive Backend [ In reply to ]
Hi,

You want to use probes and the fallback director.

Relevant documentation:
to define a probe:
https://varnish-cache.org/docs/6.4/reference/vcl.html?highlight=probe#probes
to attach it to backends:
https://varnish-cache.org/docs/6.4/reference/vcl.html?highlight=probe#backend-definition
the fallback director:
https://varnish-cache.org/docs/6.4/reference/vmod_directors.html?highlight=fallback#directors-fallback

i also wrote these blog posts a long time ago, but they are still valid:
https://info.varnish-software.com/blog/backends-load-balancing
https://info.varnish-software.com/blog/backends-load-balancing-part-2

The first one goes through probes, and the second one explores directors,
including the fallback one.

Hope that helps

--
Guillaume Quintard


On Sat, Jul 4, 2020 at 7:14 AM hamidreza hosseini <hrhosseini@hotmail.com>
wrote:

> Hi,
> I want to have 2 or 3 backends in the Varnish config file but just one of
> them workes as an active backend and whenever my active backend failed ,
> the second backend become active and respond the requests. (In other hand,
> I dont want to have two backend for responding clients and just one of them
> works at the same time, and it check the health status of my active backend
> , whenever it is was unhealthy , varnish switch to the second or third
> backend.)
> Best Regards.
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
Re: solution for Active/Passive Backend [ In reply to ]
Thanks for your answer,
I read yor blog post, you wrote there that fallback director will check the health status of the servers and it will choose one of them that is healthy(First one) , so by this explanation i dont need to define the prob for my backends to understand that my backends are healthy or not, is it true?
is this config file enough for my purpose?
"
import directors;

backend alpha1 { .host = "192.168.0.101"; }
backend alpha2 { .host = "192.168.0.201"; }
backend err { .host = "192.168.0.150"; }

sub vcl_int {
new alpha_rr = directors.round_robin();
alpha_rr.add_backend(alpha1);
alpha_rr.add_backend(alpha2);

new alpha_fb = directors.fallback();
alpha_fb.add_backend(alpha_rr.backend());
alpha_fb.add_backend(err);
}
"
Best Regards
________________________________
From: Guillaume Quintard <guillaume@varnish-software.com>
Sent: Saturday, July 4, 2020 8:11 AM
To: hamidreza hosseini <hrhosseini@hotmail.com>
Cc: varnish-misc@varnish-cache.org <varnish-misc@varnish-cache.org>
Subject: Re: solution for Active/Passive Backend

Hi,

You want to use probes and the fallback director.

Relevant documentation:
to define a probe:https://varnish-cache.org/docs/6.4/reference/vcl.html?highlight=probe#probes
to attach it to backends: https://varnish-cache.org/docs/6.4/reference/vcl.html?highlight=probe#backend-definition
the fallback director: https://varnish-cache.org/docs/6.4/reference/vmod_directors.html?highlight=fallback#directors-fallback

i also wrote these blog posts a long time ago, but they are still valid:
https://info.varnish-software.com/blog/backends-load-balancing
https://info.varnish-software.com/blog/backends-load-balancing-part-2

The first one goes through probes, and the second one explores directors, including the fallback one.

Hope that helps

--
Guillaume Quintard


On Sat, Jul 4, 2020 at 7:14 AM hamidreza hosseini <hrhosseini@hotmail.com<mailto:hrhosseini@hotmail.com>> wrote:
Hi,
I want to have 2 or 3 backends in the Varnish config file but just one of them workes as an active backend and whenever my active backend failed , the second backend become active and respond the requests. (In other hand, I dont want to have two backend for responding clients and just one of them works at the same time, and it check the health status of my active backend , whenever it is was unhealthy , varnish switch to the second or third backend.)
Best Regards.
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: solution for Active/Passive Backend [ In reply to ]
Hi,

You will have to define a probe, otherwise Varnish will consider the
backend to be healthy by default. You would then be able to manually make
it sick, but for automatic health, you need probing.

Kind regards,
--
Guillaume Quintard


On Sat, Jul 4, 2020 at 8:47 AM hamidreza hosseini <hrhosseini@hotmail.com>
wrote:

> Thanks for your answer,
> I read yor blog post, you wrote there that fallback director will check
> the health status of the servers and it will choose one of them that is
> healthy(First one) , so by this explanation i dont need to define the prob
> for my backends to understand that my backends are healthy or not, is it
> true?
> is this config file enough for my purpose?
> "
> import directors;
>
> backend alpha1 { .host = "192.168.0.101"; }
> backend alpha2 { .host = "192.168.0.201"; }
> backend err { .host = "192.168.0.150"; }
>
> sub vcl_int {
> new alpha_rr = directors.round_robin();
> alpha_rr.add_backend(alpha1);
> alpha_rr.add_backend(alpha2);
>
> new alpha_fb = directors.fallback();
> alpha_fb.add_backend(alpha_rr.backend());
> alpha_fb.add_backend(err);
> }
> "
> Best Regards
> ------------------------------
> *From:* Guillaume Quintard <guillaume@varnish-software.com>
> *Sent:* Saturday, July 4, 2020 8:11 AM
> *To:* hamidreza hosseini <hrhosseini@hotmail.com>
> *Cc:* varnish-misc@varnish-cache.org <varnish-misc@varnish-cache.org>
> *Subject:* Re: solution for Active/Passive Backend
>
> Hi,
>
> You want to use probes and the fallback director.
>
> Relevant documentation:
> to define a probe:
> https://varnish-cache.org/docs/6.4/reference/vcl.html?highlight=probe#probes
> to attach it to backends:
> https://varnish-cache.org/docs/6.4/reference/vcl.html?highlight=probe#backend-definition
> the fallback director:
> https://varnish-cache.org/docs/6.4/reference/vmod_directors.html?highlight=fallback#directors-fallback
>
> i also wrote these blog posts a long time ago, but they are still valid:
> https://info.varnish-software.com/blog/backends-load-balancing
> https://info.varnish-software.com/blog/backends-load-balancing-part-2
>
> The first one goes through probes, and the second one explores directors,
> including the fallback one.
>
> Hope that helps
>
> --
> Guillaume Quintard
>
>
> On Sat, Jul 4, 2020 at 7:14 AM hamidreza hosseini <hrhosseini@hotmail.com>
> wrote:
>
> Hi,
> I want to have 2 or 3 backends in the Varnish config file but just one of
> them workes as an active backend and whenever my active backend failed ,
> the second backend become active and respond the requests. (In other hand,
> I dont want to have two backend for responding clients and just one of them
> works at the same time, and it check the health status of my active backend
> , whenever it is was unhealthy , varnish switch to the second or third
> backend.)
> Best Regards.
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
Re: solution for Active/Passive Backend [ In reply to ]
On Sat, Jul 4, 2020 at 3:54 PM Guillaume Quintard
<guillaume@varnish-software.com> wrote:
>
> Hi,
>
> You will have to define a probe, otherwise Varnish will consider the backend to be healthy by default. You would then be able to manually make it sick, but for automatic health, you need probing.

Alternatively one can also use vmod_saintmode and retry failed fetches.

Dridi
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc