]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Report the TCP latency for TCP-only Do53, DoT and DoH backends
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 14 Mar 2023 09:22:14 +0000 (10:22 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 14 Mar 2023 09:22:14 +0000 (10:22 +0100)
Since 1.8.0 we separately record the latency for queries forwarded
over UDP and TCP, to get a better picture of what is going on.
It means we have to be careful to pick the relevant one when looking
at the latency.

pdns/dnsdist-carbon.cc
pdns/dnsdist-lua-bindings.cc
pdns/dnsdist-lua.cc
pdns/dnsdist-snmp.cc
pdns/dnsdist.hh
pdns/dnsdistdist/dnsdist-lbpolicies.cc
pdns/dnsdistdist/dnsdist-lua-ffi.cc
pdns/dnsdistdist/html/local.js

index b953180180e8e8220a5bc4a059392134efc2536e..74514ab963a0c2b375b612731e2c48857b32daf5 100644 (file)
@@ -77,6 +77,7 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)
       str << base << "responses" << ' ' << state->responses.load() << " " << now << "\r\n";
       str << base << "drops" << ' ' << state->reuseds.load() << " " << now << "\r\n";
       str << base << "latency" << ' ' << (state->d_config.availability != DownstreamState::Availability::Down ? state->latencyUsec / 1000.0 : 0) << " " << now << "\r\n";
+      str << base << "latencytcp" << ' ' << (state->d_config.availability != DownstreamState::Availability::Down ? state->latencyUsecTCP / 1000.0 : 0) << " " << now << "\r\n";
       str << base << "senderrors" << ' ' << state->sendErrors.load() << " " << now << "\r\n";
       str << base << "outstanding" << ' ' << state->outstanding.load() << " " << now << "\r\n";
       str << base << "tcpdiedsendingquery" << ' ' << state->tcpDiedSendingQuery.load() << " " << now << "\r\n";
index d6087531fa6cdf1018c24cfcd2008c897f06da3e..5246e482142e067d47f9129c0f8d44e9b31564cc 100644 (file)
@@ -119,7 +119,7 @@ void setupLuaBindings(LuaContext& luaCtx, bool client)
     });
   luaCtx.registerFunction<uint64_t(DownstreamState::*)()const>("getOutstanding", [](const DownstreamState& s) { return s.outstanding.load(); });
   luaCtx.registerFunction<uint64_t(DownstreamState::*)()const>("getDrops", [](const DownstreamState& s) { return s.reuseds.load(); });
-  luaCtx.registerFunction<double(DownstreamState::*)()const>("getLatency", [](const DownstreamState& s) { return s.latencyUsec; });
+  luaCtx.registerFunction<double(DownstreamState::*)()const>("getLatency", [](const DownstreamState& s) { return s.getRelevantLatencyUsec(); });
   luaCtx.registerFunction("isUp", &DownstreamState::isUp);
   luaCtx.registerFunction("setDown", &DownstreamState::setDown);
   luaCtx.registerFunction("setUp", &DownstreamState::setUp);
index fdce3a779f9da49cc13bf614cd34a94f47d275dc..94a5d1bb51485063f2a3dde3b17c1d4df833a84a 100644 (file)
@@ -904,10 +904,10 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
           pools += p;
         }
         if (showUUIDs) {
-          ret << (fmt % counter % s->getName() % s->d_config.remote.toStringWithPort() % status % s->queryLoad % s->qps.getRate() % s->d_config.order % s->d_config.d_weight % s->queries.load() % s->reuseds.load() % (s->dropRate) % (s->latencyUsec / 1000.0) % s->outstanding.load() % pools % *s->d_config.id) << endl;
+          ret << (fmt % counter % s->getName() % s->d_config.remote.toStringWithPort() % status % s->queryLoad % s->qps.getRate() % s->d_config.order % s->d_config.d_weight % s->queries.load() % s->reuseds.load() % (s->dropRate) % (s->getRelevantLatencyUsec() / 1000.0) % s->outstanding.load() % pools % *s->d_config.id) << endl;
         }
         else {
-          ret << (fmt % counter % s->getName() % s->d_config.remote.toStringWithPort() % status % s->queryLoad % s->qps.getRate() % s->d_config.order % s->d_config.d_weight % s->queries.load() % s->reuseds.load() % (s->dropRate) % (s->latencyUsec / 1000.0) % s->outstanding.load() % pools) << endl;
+          ret << (fmt % counter % s->getName() % s->d_config.remote.toStringWithPort() % status % s->queryLoad % s->qps.getRate() % s->d_config.order % s->d_config.d_weight % s->queries.load() % s->reuseds.load() % (s->dropRate) % (s->getRelevantLatencyUsec() / 1000.0) % s->outstanding.load() % pools) << endl;
         }
         totQPS += s->queryLoad;
         totQueries += s->queries.load();
index 784af371ab62bab8b34fd5ac188c939a93a617cd..d853a32d04eaddae84be3a8f367c7704d6b76c8e 100644 (file)
@@ -303,7 +303,7 @@ static int backendStatTable_handler(netsnmp_mib_handler* handler,
         break;
       case COLUMN_BACKENDLATENCY:
         DNSDistSNMPAgent::setCounter64Value(request,
-                                            server->latencyUsec/1000.0);
+                                            server->getRelevantLatencyUsec() / 1000.0);
         break;
       case COLUMN_BACKENDWEIGHT:
         DNSDistSNMPAgent::setCounter64Value(request,
index 88900e1dab03cf40dbfdf56c5570f06238d05156..472a729ba17088ba3ea5002d59dda03eba82f98d 100644 (file)
@@ -1048,6 +1048,14 @@ public:
     return dnsdist::Protocol::DoUDP;
   }
 
+  double getRelevantLatencyUsec() const
+  {
+    if (isTCPOnly()) {
+      return latencyUsecTCP;
+    }
+    return latencyUsec;
+  }
+
   static int s_udpTimeout;
   static bool s_randomizeSockets;
   static bool s_randomizeIDs;
index cec6769dd0fbadbc69857c1a31f5279add5a7f15..70fec893c88ada5f81a3153cb4f472186e5f5bbf 100644 (file)
@@ -40,7 +40,7 @@ template <class T> static std::shared_ptr<DownstreamState> getLeastOutstanding(c
   size_t usableServers = 0;
   for (const auto& d : servers) {
     if (d.second->isUp()) {
-      poss[usableServers] = std::make_pair(std::make_tuple(d.second->outstanding.load(), d.second->d_config.order, d.second->latencyUsec), d.first);
+      poss[usableServers] = std::make_pair(std::make_tuple(d.second->outstanding.load(), d.second->d_config.order, d.second->getRelevantLatencyUsec()), d.first);
       usableServers++;
     }
   }
index b690dd368bb52e4afcc562efa48172afd0d43408..c9fa8407ef80ef3632c1d8c66ca21927e5a0c5bc 100644 (file)
@@ -683,7 +683,7 @@ int dnsdist_ffi_server_get_order(const dnsdist_ffi_server_t* server)
 
 double dnsdist_ffi_server_get_latency(const dnsdist_ffi_server_t* server)
 {
-  return server->server->latencyUsec;
+  return server->server->getRelevantLatencyUsec();
 }
 
 bool dnsdist_ffi_server_is_up(const dnsdist_ffi_server_t* server)
index cbf9534063688fb19570be155d54136fe12ce9d5..1dc39b87aaf58fdb5bfec0f1c81af2eafd74daa2 100644 (file)
@@ -193,7 +193,7 @@ $(document).ready(function() {
                      var bouw='<table width="100%"><tr align=right><th>#</th><th align=left>Name</th><th align=left>Address</th><th>Status</th><th>Latency</th><th>Queries</th><th>Drops</th><th>QPS</th><th>Out</th><th>Weight</th><th>Order</th><th align=left>Pools</th></tr>';
                      $.each(data["servers"], function(a,b) {
                          bouw = bouw + ("<tr align=right><td>"+b["id"]+"</td><td align=left>"+b["name"]+"</td><td align=left>"+b["address"]+"</td><td>"+b["state"]+"</td>");
-                         var latency = (b["latency"] === null) ? 0.0 : b["latency"];
+                         var latency = (b["protocol"].includes("UDP") ? ((b["latency"] === null) ? 0.0 : b["latency"]) : ((b["tcpLatency"] === null) ? 0.0 : b["tcpLatency"]));
                          bouw = bouw + ("<td>"+latency.toFixed(2)+"</td><td>"+b["queries"]+"</td><td>"+b["reuseds"]+"</td><td>"+(b["qps"]).toFixed(2)+"</td><td>"+b["outstanding"]+"</td>");
                          bouw = bouw + ("<td>"+b["weight"]+"</td><td>"+b["order"]+"</td><td align=left>"+b["pools"]+"</td></tr>");
                      });