[dnsdist] server policy to failover to another pool

Pieter Lexis pieter.lexis at powerdns.com
Thu Oct 5 05:29:11 UTC 2017

Hi Justin,

On Wed, 4 Oct 2017 17:05:43 -0400
Justin Valentini <justin.valentini at oracle.com> wrote:

> I'm trying to create a Lua server policy to use the least outstanding 
> policy on one pool but send traffic to another pool if none of the 
> servers in the first pool are up.
> Here's my Lua code which is *not* working:
> function useLocalBindAsLastResort(servers, dq)
>    primaryServer = leastOutstanding.policy(getPoolServers("primary"), dq)
>    if primaryServer
>    then
>      return primaryServer
>    else
>      return leastOutstanding.policy(getPoolServers("secondary"), dq)
>    end
> end
> setServerPolicyLua("useLocalBindAsLastResort", useLocalBindAsLastResort)
> The problem seems to be with the conditional as it never seems to hit 
> the secondary pool, even when I test it by manually setting all servers 
> in the primary pool to DOWN. I'm not quite sure what the check needs to 
> look like though. Thoughts?

I _think_ (but Remi will probably correct me on this) that we discover that all the servers in a pool are down, we don't fire off the policy (as there is nothing to policy upon). Looking at the current ServerPolicies, there is no way to configure something like this. We might need an 'OrderedLeastOutstandsing' policy where packets are sent to the up servers with the lowest order, only sending to the others if the one with a lower order are down. You could create this as a LuaPolicy as well.

If you want to use existing Policies, you could 'fake' this with wrandom. Just give the secondairy servers a very big (1M+) weight. They will then receive one in a million packets when all the other servers are up.

Best regards,


Pieter Lexis
PowerDNS.COM BV -- https://www.powerdns.com

More information about the dnsdist mailing list