]> git.ipfire.org Git - thirdparty/pdns.git/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 12:37:48 +0000 (13:37 +0100)
pdns/pdns_recursor.cc
pdns/rec-snmp.cc
pdns/rec_channel_rec.cc
pdns/recursordist/RECURSOR-MIB.txt
pdns/recursordist/docs/metrics.rst
pdns/syncres.hh

index 7437e718522df3e9c6f2a790a37f1da1890e1230..065833eb5332e4a7d5f891ea9a5e157b5dce5e2c 100644 (file)
@@ -2889,9 +2889,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 handler */ 1 + g_numDistributorThreads + worker;
index 415a36ff30de362efb4bac4ee8fda4da7f5452ae..45b48cea8deb9dc598866ff423ac1de39cf74550 100644 (file)
@@ -114,6 +114,7 @@ static const oid dnssecAuthenticDataQueriesOID[] = { RECURSOR_STATS_OID, 95 };
 static const oid dnssecCheckDisabledQueriesOID[] = { RECURSOR_STATS_OID, 96 };
 static const oid variableResponsesOID[] = { RECURSOR_STATS_OID, 97 };
 static const oid specialMemoryUsageOID[] = { RECURSOR_STATS_OID, 98 };
+static const oid rebalancedQueriesOID[] = { RECURSOR_STATS_OID, 99 };
 
 static std::unordered_map<oid, std::string> s_statsMap;
 
@@ -320,5 +321,6 @@ RecursorSNMPAgent::RecursorSNMPAgent(const std::string& name, const std::string&
   registerCounter64Stat("policy-result-truncate", policyResultTruncateOID, OID_LENGTH(policyResultTruncateOID));
   registerCounter64Stat("policy-result-custom", policyResultCustomOID, OID_LENGTH(policyResultCustomOID));
   registerCounter64Stat("special-memory-usage", specialMemoryUsageOID, OID_LENGTH(specialMemoryUsageOID));
+  registerCounter64Stat("rebalanced-queries", rebalancedQueriesOID, OID_LENGTH(rebalancedQueriesOID));
 #endif /* HAVE_NET_SNMP */
 }
index bb5bfba56ba10e75b2bbcccb5fe6b6f1acf9f2b7..453885bad404b07bea67f800ccaa0a16b002736f 100644 (file)
@@ -1102,6 +1102,8 @@ void registerAllStats()
   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);
+
   /* make sure that the ECS stats are properly initialized */
   SyncRes::clearECSStats();
   for (size_t idx = 0; idx < SyncRes::s_ecsResponsesBySubnetSize4.size(); idx++) {
index 2af4621d08d6daefe3406205d5f5e20e586246ba..6b9fac22e1bd65cfa66c5c1d0431a759301e194a 100644 (file)
@@ -817,6 +817,14 @@ specialMemoryUsage OBJECT-TYPE
         "Memory usage (more precise bbut expensive to retrieve)"
     ::= { stats 98 }
 
+rebalancedQueries OBJECT-TYPE
+    SYNTAX Counter64
+    MAX-ACCESS read-only
+    STATUS current
+    DESCRIPTION
+        "Number of queries re-distributed because the first selected worker thread was above the target load"
+    ::= { stats 99 }
+
 ---
 --- Traps / Notifications
 ---
@@ -957,6 +965,8 @@ recGroup OBJECT-GROUP
         dnssecAuthenticDataQueries,
         dnssecCheckDisabledQueries,
         variableResponses,
+        specialMemoryUsage,
+        rebalancedQueries,
         trapReason
     }
     STATUS current
index 3fb0ee71ed17902cf10b953ee1804e1959a07a20..1fbf805763666115d3c8d23a90567d9bed1161c7 100644 (file)
@@ -399,6 +399,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 d808668b4970ec9091cee0d572fd5cd94899eff4..bba453e2cff1ce30b07be274d5ee249509ba2020 100644 (file)
@@ -957,6 +957,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