It's possible to have dinamic backends?

Guillermo Pérez bisho at tuenti.com
Thu Sep 9 20:34:24 CEST 2010


We want to deploy several Varnish as a cache & routing layer to a lot
of backends with different contents. We have developed a C module for
the rewriting and calculation of which backend host to use, but I have
not found a way to dynamically configure which server to use as
backend.

The use case is the following: We have images assigned to "storage
ids". Each storage id is replicated in at least two image backend
servers. We can move the storage id from one backend server to other
to rebalance, when one backend fails, etc. Our module will calculate
the actual mapping of storage id -> backend server to query.

With a short list of backends images1, 2, 3 its easy and manageable to
configure them in the backends section, and then do set req.backend =
images1. But when your number of backends is several dozens, it's a
pain to manage.

sub vcl_recv {
	C{
		if (get_server_for_url) {
			VRT_SetHdr(sp, HDR_REQ, "\010X-Panel:",
					get_server_for_url(VRT_r_req_url(sp))
				);
		}
	}C

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

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.

Thanks a lot.

-- 
Guille -ℬḭṩḩø- <bisho at tuenti.com>
:wq




More information about the varnish-dev mailing list