On Fri, Nov 4, 2016 at 3:55 PM, komu wairagu <komu...@gmail.com> wrote:
> Hi guys, > > I'm a little confused by the wording on the official haproxy ver1.6 > documentation(https://cbonte.github.io/haproxy-dconv/1.6/ > configuration.html) > especially as concerning dns resolution. > > Here's a section of my haproxy config: > > ## start config > > resolvers my_dns_resolver > #Google name servers > nameserver dns1 8.8.8.8:53 > nameserver dn2 8.8.4.4:53 > resolve_retries 30 > timeout retry 1s > hold valid 2010 > > frontend my_frontend > bind *:80 > default_backend my_backend > > > backend my_backend > balance roundrobin > server my_domain my_domain.com check resolvers my_dns_resolver inter > 2000 > > ## end config > > So my question is, > How often will haproxy (version 1.6) do a dns resolution? Is it every > 2000 ms(health check interval) or > every 10ms (2010 modulo 2000) ? > > The documenation says: > > `Note: since the name resolution is triggered by the health checks, a new > resolution is triggered after <period> modulo the <inter> parameter > of > the healch check.` > > but I'm getting confused by the wording. > I have two interpretations from reading that documentaion; > 1. dns resolution is triggered by health checks and thus will happen > (<period> modulo the <inter>) milliseconds after the health check. > 2. dns resolution will happen every (<period> modulo the <inter>) > milliseconds. > > So if we start at time 00.00.00.00(hh.mm.ss.ms) > for case 1 above health check happens at 00.00.02.00 and first dns > resolution happens at > 00.00.02.10 and second one at 00.00.04.10 etc > while for case 2 above health check happens at 00.00.02.00 and first > dns resolution happens at > 00.00.02.10 and second one at 00.00.02.20 etc > > > thanks, > Komu W. > > Hi Komu, Technically, HAProxy's internal scheduler will wake up the health check task at <inter> period. Before processing the check itself, HAProxy will check if the last resolution result is obsolete, so it 'now > last-resolution + hold valid' period. This means: - smallest DNS resolution period will be <inter> if DNS resolution period is lower than <inter> - if DNS resolution period is greater than <inter>, then next DNS resolution will be after X times <inter>, X being the rounded ratio between <inter> and DNS resolution period With some examples: - inter = 2s, DNS hold valid = 1s, then DNS resolution will happen every 2s - inter = 2s, DNS hold valid = 5s, then DNS resolution will happen every 6s - inter = 2s, DNS hold valid = 10s, then DNS resolution will happen every 10s Baptiste