[Pdns-dev] Question regarding life time of backend threads in PDNS
Seema Datar
sdatar at yahoo-inc.com
Mon Nov 11 13:09:53 CET 2013
Hi All,
I needed a rough idea about the lifetime of the threads. The reason being
I am introducing stats in the backends and the stats will get reset every
time the Backend is destroyed. If the backends get destroyed say once a
day or every few hours, I can live with it. However, if they get destroyed
every few minutes, then I have to think of an alternate solution.
Also, can I assume that if I have 8 threads of execution, there will be
only 8 instances of the Backend running?
Thanks,
Seema
>On 11/8/13 1:33 PM, "Seema Datar" <sdatar at yahoo-inc.com> wrote:
>
>>Thanks. That helps.
>>
>>We use the DNSBackend so we should be able to use its destructor for
>>cleanup.
>>
>>Also, I am assuming that DNSBackend termination will result in the thread
>>termination too.
>>
>>Thanks,
>>Seema
>>
>>On 11/8/13 1:03 PM, "Aki Tuomi" <cmouse at youzen.ext.b2.fi> wrote:
>>
>>>On Fri, Nov 08, 2013 at 07:22:40AM +0000, Seema Datar wrote:
>>>> Hi All,
>>>>
>>>> Does anybody have more information on this?
>>>>
>>>> Thanks,
>>>> Seema
>>>>
>>>> Hi All,
>>>>
>>>> We have a use case where we use PDNS with 8 backend threads. We needed
>>>>to save thread specific data in an mmap. However, I came across the
>>>>following in PDNS documentation -
>>>>
>>>> PowerDNS may instantiate multiple instances of your backend, or
>>>>destroy
>>>>existing copies and instantiate new ones. Backend code should therefore
>>>>be thread-safe with respect to its static data. Additionally, it is
>>>>wise
>>>>if instantiation is a fast operation, with the possible exception of
>>>>the
>>>>first construction.
>>>>
>>>> The questions I had are -
>>>>
>>>>
>>>> 1. What is the lifetime of a backend thread?
>>>> 2. How often does a thread get destroyed and a new thread get
>>>>created?
>>>> 3. Is there any interface available to do a cleanup before the
>>>>thread ends?
>>>>
>>>> Thanks,
>>>> Seema
>>>
>>>Lifetime of a backend thread is dependant on several factors, and the
>>>only
>>>thing you can assume is that it's not something you can rely on.
>>>
>>>The only thing backend module can use for cleanup is the destructror of
>>>the
>>>backend class.
>>>
>>>Or if you use remote/pipebackend, you can wire it to look for EOF or
>>>signal
>>>and cleanup when either one is received before dying out.
>>>
>>>Aki Tuomi
>>
>
More information about the Pdns-dev
mailing list