Questions on backend allocations

Dridi Boukelmoune dridi at varni.sh
Wed Apr 15 00:23:50 CEST 2015


Hi,

It turns out my trainees were so quiet during exercises that I could
explore this a bit more.

I have come to the point where you don't need a backend declaration in
your VCL, as long as you have a director that will dynamically create
one. Once backend check was deferred to *after* vcl_init, it made very
easy to allow a director to become the default backend.

See the test d00007.vtc for a pure dynamic backend:

varnish v1 -vcl {
        import ${vmod_debug};

        sub vcl_init {
                new s1 = debug.dyn("${s1_addr}", "${s1_port}");
        }
} -start

See the test d00008.vtc for a director as the default:

varnish v1 -vcl+backend {
        import ${vmod_directors};

        # no need for `set bereq.backend = default;`
        sub vcl_init {
                new default = directors.round_robin();
                default.add_backend(s1);
                default.add_backend(s2);
        }
} -start

There are still caveats with the current implementation, and it's still not
enough to implement a new dns director. Dynamically created backend
won't receive events, which is not a problem *so far* since we can't pass
probes to VMODs yet. Instead of emitting per-backend code for events,
it could rely on backend_find() to fire events on both static and dynamic
backends.

Comments?

Cheers,
Dridi

On Mon, Apr 13, 2015 at 10:17 AM, Dridi Boukelmoune <dridi at varni.sh> wrote:
> Hi,
>
> It turned out you couldn't properly create backends dynamically, or at
> least remove them. Please find attached a patch set that fixes that,
> and adds a "director" capability to the debug vmod with an initial
> test case. This is still incomplete, and I want to push this further. For
> example I've created a Backend_added log record, but nothing for
> deletion.
>
> Before I do anything else, I'll wait for feedback :)
>
> Cheers,
> Dridi
>
> PS. today I'm doing training and the customer is blocking IRC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Rename-static-function-VCL_Load-to-vcl_load.patch
Type: text/x-patch
Size: 1474 bytes
Desc: not available
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20150415/56b4940c/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Defer-backend-existence-check-after-vcl_init.patch
Type: text/x-patch
Size: 3030 bytes
Desc: not available
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20150415/56b4940c/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-VCL-doesn-t-require-static-backends-anymore.patch
Type: text/x-patch
Size: 2894 bytes
Desc: not available
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20150415/56b4940c/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-Built-in-directors-now-register-themselves.patch
Type: text/x-patch
Size: 4752 bytes
Desc: not available
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20150415/56b4940c/attachment-0007.bin>


More information about the varnish-dev mailing list