[Pdns-users] gmysql backend & queries

matthew zeier mzeier at gmail.com
Sun Apr 25 23:44:49 UTC 2010


I want to change the query pdns uses to mysql to only search for "enabled" records.  And them, in the case of a CNAME RR, use a slightly different query.  Basically trying to build a CDN load balancer.

I'm not sure which query really needs to be changed (I changed them all and get the right results only if I specify a query type of '-t cname').  

My database: http://mrz.pastebin.mozilla.org/718414

For the CNAME RRs, I only want to return one entry.  I've appended the following clause :

   and enabled order by rand()*(1/weight) limit 1

I want to nearly evenly split traffic between both CDNs with the default origin (incase they both go offline).

Like I said, I added this to all the queries but I'm not sure that's right.  Any guidance?

gmysql-basic-query=select content,ttl,prio,type,domain_id,name from records where type='%s' and name='%s' and enabled order by rand()*(1/weight) limit 1
gmysql-id-query=select content,ttl,prio,type,domain_id,name from records where type='%s' and name='%s' and domain_id=%d and enabled order by rand()*(1/weight) limit 1
gmysql-any-query=select content,ttl,prio,type,domain_id,name from records where name='%s'  and enabled order by rand()*(1/weight) limit 1
gmysql-any-id-query=select content,ttl,prio,type,domain_id,name from records where name='%s' and domain_id=%d and enabled order by rand()*(1/weight) limit 1





More information about the Pdns-users mailing list