[Pdns-dev] My Backend Getting called multiple times

Ruben d'Arco cyclops at prof-x.net
Tue Nov 20 23:48:13 CET 2012


Hi,

PowerDNS does not have a configurable timeout for its backends. If you backend is slow, the query response is slow.
PowerDNS has a query (and packet)cache to make sure the backend isn't queried for every incoming.

If you backend only has A records, then simply only respond to those lookups. Don't forget that ANY would also include A records. SOA records indicate that a zone/domain exists, so you will also need to respond to that correctly as well.

Could you also describe what you are trying to do? This way we can suggest a good approach.

Regards,
      Ruben

Nikhil Bose <nikhilbose11 at gmail.com> wrote:

>Thanks Ruben,
>
>Also if I am serving only A records from my backend, and if my backend
>is a
>bit slow, then is there some place I can set a timeout before PowerDNS
>calls my lookup.
>
>As from the example in Writer's guide, suppose I am only serving A
>records,
>but if my backend is slow, PDNS queries again for the A record, that
>means
>my else part will hit again if my backend is slow,
>so is there any timeout I can set before PDNS queries back to my
>backend.
>
>Thanks,
>Nikhil
>
>void lookup(const QType &type, const string &qdomain, DNSPacket *p, int
>zoneId)
>  {
>    if(type.getCode()!=QType::A || qdomain!="random.powerdns.com")  //
>we only know about random.powerdns.com A
>d_answer="";                                                  // no
>answer
>    else {
>      ostringstream os;
>os<<random()%256<<"."<<random()%256<<"."<<random()%256<<"."<<random()%256;
>      d_answer=os.str();                                           //
>our random ip address
>    }
>  }
>
>
>
>On Fri, Nov 16, 2012 at 4:29 PM, Ruben d'Arco <cyclops at prof-x.net>
>wrote:
>
>> Hi Nikhil,
>>
>> This is by design. PowerDNS will try to get the soa record to see if
>it is
>> authorative for the domain. It will also try to move up to the root
>to see
>> if a backend is authorative for that. If it is, it will continue with
>the
>> actual records it needs.
>> Also, for things like CNAME and MX, it will try to resolve those as
>well.
>>
>> So, it is normal and canot be avoided. Just implement the fuctions as
>> described in the backend writers guide and powerdns does the rest for
>you!
>>
>> Regards,
>>      Ruben
>>
>> Nikhil Bose <nikhilbose11 at gmail.com> wrote:
>>
>> >Hi All,
>> >
>> >First of all thanks for the help provided. As Peter in one of my
>> >earlier
>> >queries gave me a pointer and following that it is quite trivial to
>> >create
>> >our own Backend in PowerDNS and using getRemote(), I was able to
>> >retrieve
>> >the Client's resolver IP.
>> >
>> >PowerDNS is indeed quite simple to extend. Thanks for this
>> >architecture.
>> >
>> >I have one problem though. My backend is getting called multiple
>times.
>> >Even though I just send a single query using the host command.
>> >Just to show I put some output statements and these are printed
>after I
>> >sent the client query
>> >
>> >Here's the console output:
>> >
>>
>>
>>***************************************************************************************
>> >Nov 16 11:20:26 Creating backend connection for TCP
>> >Constructor called
>> >% Nov 16 11:20:26 [bindbackend] Parsing 1 domain(s), will report
>when
>> >done
>> >Nov 16 11:20:26 [bindbackend] parsing 'example.com' from file
>> >'/etc/bind/example.com.zone'
>> >Nov 16 11:20:26 [bindbackend] Done parsing domains, 0 rejected, 1
>new,
>> >0
>> >removed
>> >Constructor called
>> >Nov 16 11:20:26 About to create 3 backend threads for UDP
>> >Constructor called
>> >Constructor called
>> >Constructor called
>> >Constructor called
>> >Constructor called
>> >Constructor called
>> >Nov 16 11:20:26 Done launching threads, ready to distribute
>questions
>> >Nov 16 11:20:35 Distributor misses a thread (4<5), spawning new one
>> >looked up
>> >looked up
>> >looked up
>> >looked up
>> >Constructor called
>> >Constructor called
>>
>>
>>***************************************************************************************
>> >
>> >How I can reduce this to a single lookup() call from the PowerDNS to
>my
>> >Backend?. Even constructor is called many times. Can this be
>configured
>> >anywhere?
>> >
>> >Thanks,
>> >Nikhil.
>> >
>> >
>>
>>------------------------------------------------------------------------
>> >
>> >_______________________________________________
>> >Pdns-dev mailing list
>> >Pdns-dev at mailman.powerdns.com
>> >http://mailman.powerdns.com/mailman/listinfo/pdns-dev
>>
>> --
>> Regards,
>>           Ruben
>>

--
Regards,
          Ruben


More information about the Pdns-dev mailing list