It's possible to have dinamic backends?

Nils Goroll slink at schokola.de
Fri Sep 10 13:53:57 CEST 2010


Hi Guillermo,

> So, going back to the point, there is any way of configuring the host
> to use for a request, without it being defined in the backends
> section? I can generate the IP if needed.

I usually use perl code to generate the VCL, that way can just generate the
backend selector

	if (req.http.X-Panel = "1") {
		set req.backend = server1;
	} else if (req.http.X-Panel = "2") {
		set req.backend = server2;
....

An alternative is the VSLP director I have written. I haven't published it yet,
as I have quite a lot of open tickets with patches I proposed, and I don't see
much value in preparing patches if the core developers don't have enough
resources to review them. The director is ready, I am using it in production on
a high traffic site.

In
http://lists.varnish-cache.org/pipermail/varnish-dev/2010-March/002420.html
I have described the basic design.

IIUC, the VSLP director would do what you need. VCL inline code would look
something like

	C{
		if (get_server_for_url) {
			/* pseudo-VCL: set dir.key = get_server_for_url(req.url) */
			VRT_l_dir_key_int(sp, get_server_for_url(VRT_r_req_url(sp)));
		}
	}C

Server selection is then as

	server = key % nservers

nserver being the number of servers, plus additional logic when the server is
down etc.


Nils




More information about the varnish-dev mailing list