From: Remi Gacogne Date: Wed, 27 Mar 2019 11:10:37 +0000 (+0100) Subject: rec: Add a 'rebalanced-queries' metric X-Git-Tag: rec-4.1.12~1^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47365ba09d3fe8fc885bf6b2135992a57a02ac6f;p=pdns rec: Add a 'rebalanced-queries' metric (cherry picked from commit 596bf48219cb82379bf872e746dd7f626b582342) --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index a9f317208..841084575 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -2399,9 +2399,13 @@ static unsigned int selectWorker(unsigned int hash) unsigned int worker = hash % g_numWorkerThreads; /* at least one server has to be below the average load */ - while(load[worker] > targetLoad) { - // cerr<<"worker "< targetLoad) { + ++g_stats.rebalancedQueries; + do { + // cerr<<"worker "< targetLoad); } return /* skip distributor */ 1 + worker; diff --git a/pdns/rec-snmp.cc b/pdns/rec-snmp.cc index 46697550b..f62d8b636 100644 --- a/pdns/rec-snmp.cc +++ b/pdns/rec-snmp.cc @@ -292,6 +292,5 @@ RecursorSNMPAgent::RecursorSNMPAgent(const std::string& name, const std::string& registerCounter64Stat("policy-result-nodata", policyResultNodataOID, OID_LENGTH(policyResultNodataOID)); registerCounter64Stat("policy-result-truncate", policyResultTruncateOID, OID_LENGTH(policyResultTruncateOID)); registerCounter64Stat("policy-result-custom", policyResultCustomOID, OID_LENGTH(policyResultCustomOID)); - #endif /* HAVE_NET_SNMP */ } diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 0ae865e7f..4d5d625b6 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -988,6 +988,8 @@ void registerAllStats() addGetStat("policy-result-nodata", &g_stats.policyResults[DNSFilterEngine::PolicyKind::NODATA]); addGetStat("policy-result-truncate", &g_stats.policyResults[DNSFilterEngine::PolicyKind::Truncate]); addGetStat("policy-result-custom", &g_stats.policyResults[DNSFilterEngine::PolicyKind::Custom]); + + addGetStat("rebalanced-queries", &g_stats.rebalancedQueries); } static void doExitGeneric(bool nicely) diff --git a/pdns/recursordist/docs/metrics.rst b/pdns/recursordist/docs/metrics.rst index a3519010f..70b69cbcd 100644 --- a/pdns/recursordist/docs/metrics.rst +++ b/pdns/recursordist/docs/metrics.rst @@ -370,6 +370,12 @@ questions ^^^^^^^^^ counts all end-user initiated queries with the RD bit set +rebalanced-queries +^^^^^^^^^^^^^^^^^^ +.. versionadded:: 4.1.12 + +number of queries balanced to a different worker thread because the first selected one was above the target load configured with 'distribution-load-factor' + resource-limits ^^^^^^^^^^^^^^^ counts number of queries that could not be performed because of resource limits diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 70ef510bb..75e28b05f 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -916,6 +916,7 @@ struct RecursorStats std::atomic dnssecValidations; // should be the sum of all dnssecResult* stats std::map > dnssecResults; std::map > policyResults; + std::atomic rebalancedQueries{0}; }; //! represents a running TCP/IP client session