[bind10-dev] How to implement query counters in auth module?
Jelte Jansen
jelte at isc.org
Wed Sep 15 13:49:29 UTC 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 09/15/2010 12:56 PM, Naoki Kambe wrote:
> Hi Jelte-san,
>
> Thanks for comments.
>
>> I took a look at the commit you made yesterday (r2921), and as you already
>> commented in the source, that is an extremely inefficient way to do the
>> counting; it constructs a msgq message, sends it, and waits for a response from
>> the stats module.
>>
>> AFAICT, this would happen on every query...
> Yes, that's right. But I want to resolve this problem.
>
>> If we do go for a 'push' approach similar to this I'd much rather see it
>> implemented as something that sends the stats out periodically (like once every
>> X seconds, or even minutes), optionally with a command on the command channel
>> that tells it to send it out right away. Perhaps asio timers can help out here?
> Yeah, I think this periodical approach is more reasonable. I try to research this "asio timers".
>
> BTW, I want to know how to hold statistics data in auth until it sends to stats.
>
More generally than for auth; I think each module that collects statistics
should have a module-specific data structure (or class in the case of c++), that
holds those statistics. That class would have module-specific calls for
incrementing counters, and setting other statistics values. It would also have
either a way to convert the statistics it created to a message that can be sent
to the statistics module (or perhaps it could even do that automatically, but in
that sense I don't really know at this point how we would get the interaction
with the cc session into it). For such common functionality we could make an
abstract base class that each 'statistics-stub' would implement;
Something like:
class Statistics {
public:
virtual ElementPtr createMsg() = 0;
virtual reset() = 0;
}
Then for auth specifically, if we want to gather statistics on udp and tcp queries;
class AuthStatistics : public Statistics {
public:
AuthStatistics() : udp_q_count(0), tcp_q_count(0);
increaseUDPCount();
increaseTCPCount();
virtual ElementPtr createMsg();
virtual reset();
private:
udp_q_count;
tcp_q_count;
}
AuthStatistics::createMsg() {
<create that message and send it, like the example does now>
if (success) {
reset();
}
}
or something like that.
Then the big question is how to make that run periodically, and perhaps instead
of having a createMsg() make a sendStats() that does all the message handling too...
Another question is whether we really want the statistics module to respond to
this, we could also make it fire-and-forget (saving us the danger of having the
auth module hang for [timeout] seconds if the statistics collector disappeared)
Jelte
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyQzukACgkQ4nZCKsdOncWvRACfb18BSzPhfSXSduhCWShrhOhM
TKwAoI8Nflz5ZvHpM4G9Khw3p7+9xt98
=0Y5s
-----END PGP SIGNATURE-----
More information about the bind10-dev
mailing list