Hostnames in backend definition...

david raistrick drais at
Tue Dec 13 18:22:06 CET 2011

On Tue, 13 Dec 2011, Hugo Cisneiros (Eitch) wrote:

> I'm setting up varnish to access a load balancer from amazon ec2. I
> have two problems:

For those of us familiar with EC2 architecture, can I get some 

You're trying to use varnish in front of ELB, with the ELB hostnames as 
your backends?

I would strongly recommend against this.

> - since the IP address for the load balancer changes very often, does
> varnish obey the ttl rule for resolving the hostname if I specify the
> hostname in vcl?

...for exactly this reason.

You have no control, knowledge, or insight into when the IP address behind 
the ELB hostname changes, and varnish effectively caches the hostname on 
startup.  When the internal IP of ELB changes (and it will!) your traffic 
will stop.

> - i can use multiple availability zones, meaning the hostname will
> resolve to 4 IPs, one for each zone. I got an error saying that
> varnish couldn't handle multiple IP addresses on backend definition,
> so I chose only one IP and it works :) is there a way to use multiple
> ips?

You have to define each AZ as a seperate backend in this case (using 
hostnames or IP addresses), but you have the same problems as above.

I've sort of been threatening to get one of my team to work up a patch to 
varnish to do some DNS sanity, but until it actually becomes a major 
blocker for us (we have other workarounds in place - like not using ELB 
and using internal dynamic config re-generators) I can't get the resource 
to do it...

I personally feel that 99% of the software proxy/loadbalancing solutions 
are in sorry shape when it comes to dealing with an environment like 
AWS/EC2 where dynamic dhcp and dynamic dns hostnames are a fact of life.

david raistrick
drais at   

More information about the varnish-misc mailing list