]> granicus.if.org Git - pdns/commitdiff
rec: Add a 'rebalanced-queries' metric
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 27 Mar 2019 11:10:37 +0000 (12:10 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 27 Mar 2019 15:54:43 +0000 (16:54 +0100)
(cherry picked from commit 596bf48219cb82379bf872e746dd7f626b582342)

pdns/pdns_recursor.cc
pdns/rec-snmp.cc
pdns/rec_channel_rec.cc
pdns/recursordist/docs/metrics.rst
pdns/syncres.hh

index a9f317208b8c7a0bcbf4c0f4936df33c5f6c6bbc..8410845758dad3614dd48f1dbda2b7803c86ceb3 100644 (file)
@@ -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 "<<worker<<" is above the target load, selecting another one"<<endl;
-    worker = (worker + 1) % g_numWorkerThreads;
+  if (load[worker] > targetLoad) {
+    ++g_stats.rebalancedQueries;
+    do {
+      // cerr<<"worker "<<worker<<" is above the target load, selecting another one"<<endl;
+      worker = (worker + 1) % g_numWorkerThreads;
+    }
+    while(load[worker] > targetLoad);
   }
 
   return /* skip distributor */ 1 + worker;
index 46697550b841bfbdae1392622039e7a06fa14d6c..f62d8b636b37deff4303f93852c465d548c45b8e 100644 (file)
@@ -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 */
 }
index 0ae865e7f1f2e6272914b37ba3a82619fa88e1bc..4d5d625b63eb1f3a4cd1c93adf9bf7c883a61f3b 100644 (file)
@@ -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)
index a3519010f5b913bd6826f2790ff2371879a3f4a9..70b69cbcd94fcc1f56e78de5dd1b472fdf557a19 100644 (file)
@@ -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
index 70ef510bbe4abfa48ee4588fe9997c6d7fb999e1..75e28b05f4c72d88573a1e144d3772b4b229d9d9 100644 (file)
@@ -916,6 +916,7 @@ struct RecursorStats
   std::atomic<uint64_t> dnssecValidations; // should be the sum of all dnssecResult* stats
   std::map<vState, std::atomic<uint64_t> > dnssecResults;
   std::map<DNSFilterEngine::PolicyKind, std::atomic<uint64_t> > policyResults;
+  std::atomic<uint64_t> rebalancedQueries{0};
 };
 
 //! represents a running TCP/IP client session