thierry.magnien at sfr
Nov 15, 2011, 2:50 AM
Post #1 of 1
[PATCH proposal] RE: Backend DNS lookup refresh
Here is a first version of a patch to add the "vcl.reload" function to CLI, in order to refresh DNS lookups without having to send a new VCL or restart varnish.
It is far from perfect but may be used as a starting point. It applies on master and of course all comments are welcome.
De : varnish-misc-bounces [at] varnish-cache [mailto:varnish-misc-bounces [at] varnish-cache] De la part de MAGNIEN, Thierry
Envoyé : jeudi 3 novembre 2011 17:15
À : 'varnish-misc [at] varnish-cache' (varnish-misc [at] varnish-cache)
Objet : Backend DNS lookup refresh
We are dealing with a great number of backends in our VCL file and we have problems with some backends changing IP address (for example when hosted on services such as Amazon S3, that switch IP address without telling anyone).
We would like to be able to refresh the DNS resolution of backends when needed and after a quick look at the source code, it seems there are several ways to handle this.
I would like to get your feeling about what would be the best solution before trying to write a patch, so here are my thoughts, just as it comes out of my mind ;-)
DNS resolution of backends is done when the VCL is loaded. IP address is stored in the compiled VCL as a sockaddr struct.
The first way to solve the problem would be to implement a "vcl reload" CLI function. In that case, this needs some tricks to be able to recompile a VCL which has the same name of the one used.
A 2nd way would be to make backend IP addresses resolved when needed (at first backend request and then cached for a "TTL" time), and not at VCL loading. However, this breaks most of the the optimization brought by the sockaddr structure.
A point discussed quickly with Per Buer on IRC was to have probes checking the IP addresses of the backends and update when an IP change is detected.
All this makes me think that it's not so easy as it could seem, and that's why I would accept any advice/idea/comment about this.
varnish-misc mailing list
varnish-misc [at] varnish-cache