So I'm setting up a test varnish server, and have configured configured a director block that looks something like:<div><br></div><div><div>director www dns {</div><div> .list = {</div><div> .port = "80";</div>
<div> "<a href="http://10.1.55.165/32" target="_blank">10.1.55.165/32</a>";</div><div> "<a href="http://10.1.54.126/32" target="_blank">10.1.54.126/32</a>";</div><div> "<a href="http://10.1.222.1/32" target="_blank">10.1.222.1/32</a>";</div>
<div> }</div><div> .ttl = 5m;</div><div> .suffix = ""; </div><div>}</div></div><div><br></div><div>(IP addressed changed to protect the innocent)</div><div><br></div><div><br></div><div>There is a valid DNS entry for each of 3 domains, each pointing at one of those addresses.</div>
<div><br></div><div>When testing, this appears to do what I would like - which is cache for 3 unrelated sites. </div><div><br></div><div>For now, I change my local resolver to, for my test client, point the domains at the varnish server, while having a .suffix of "" means they'll look up the real public IPs of the semi-live sites and it will cache those sites for just me.</div>
<div><br></div><div>Eventually I will point public DNS for those sites at the varnish server and maintain a domain-to-IP mapping in my DNS server (hm /etc/hosts on varnish server? nsswitch works right?)</div><div><br></div>
<div>Ideally I'd like to just load a config file with public.dns.name./<a href="http://backend.dns.name" target="_blank">backend.dns.name</a>. mappings or public.dns.name./IP mappings but I've found several archived discussions of this (e.g. dns resolved at vcl compilation time...) that doesn't show promise for now. I guess I'll just have to update the config (scripted) if a domain changes back-end IP address. </div>
<div><br></div><div>My real question is: How efficient is this for a large number of hosts? say 1K? 10K? Is the hostname to IP lookup efficient? </div><div><br></div><div>I know that having many sites all cached separately will not be great for cache hit rate.... I believe that if it becomes a problem I can throw more ram and SSD swap at that problem, to some extent anyway.</div>
<div><br></div><div><br></div><div>I guess an alternative for me would be to write my own director code that included some file with hostname/backend mappings and compiled it into the VCL along with a simple hash. or maybe just some inline C that would allow:</div>
<div><br></div><div>sub vcl_recv {</div><div> req.backend = myDictionaryLookup(req.http.host)</div><div>...</div><div>}</div><div><br></div><div>rather than having to do 1000 if/elseif/elseif blocks....</div><div><br>
</div><div>Is there some other easier way to do this? would the DNS director perform adequately?</div><div><br></div><div>Thanks.</div><div><br></div><div>Fred Clift</div><div><br></div>