From: Remi Gacogne Date: Thu, 19 Apr 2018 15:03:54 +0000 (+0200) Subject: rec: Add a new max-udp-queries-per-round setting X-Git-Tag: dnsdist-1.3.1~68^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5886e6adad3c19e3490fba1dc7e580defb83eee;p=thirdparty%2Fpdns.git rec: Add a new max-udp-queries-per-round setting This new setting limits the number of UDP queries we attempt to handle after being woken up by the multiplexer and before returning back to process other events. Before this, we could end up trying to process queries after queries and almost never return from handleNewUDPQuestion() to process new events, meaning we could eventually end up never scheduling new mthreads or handle responses from authoritative servers for a long time, only sending responses for packetcache hits and creating new mthreads. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index c396999643..4cb9df415d 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -146,6 +146,7 @@ static std::shared_ptr g_initialDomainMap; // new threads static std::shared_ptr g_initialAllowFrom; // new thread needs to be setup with this static NetmaskGroup g_XPFAcl; static size_t g_tcpMaxQueriesPerConn; +static size_t s_maxUDPQueriesPerRound; static uint64_t g_latencyStatSize; static uint32_t g_disthashseed; static unsigned int g_maxTCPPerClient; @@ -1996,7 +1997,7 @@ static void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var) fromaddr.sin6.sin6_family=AF_INET6; // this makes sure fromaddr is big enough fillMSGHdr(&msgh, &iov, cbuf, sizeof(cbuf), data, sizeof(data), &fromaddr); - for(;;) + for(size_t counter = 0; counter < s_maxUDPQueriesPerRound; counter++) if((len=recvmsg(fd, &msgh, 0)) >= 0) { firstQuery = false; @@ -3309,6 +3310,7 @@ static int serviceMain(int argc, char*argv[]) g_tcpTimeout=::arg().asNum("client-tcp-timeout"); g_maxTCPPerClient=::arg().asNum("max-tcp-per-client"); g_tcpMaxQueriesPerConn=::arg().asNum("max-tcp-queries-per-connection"); + s_maxUDPQueriesPerRound=::arg().asNum("max-udp-queries-per-round"); if (::arg().mustDo("snmp-agent")) { g_snmpAgent = std::make_shared("recursor", ::arg()["snmp-master-socket"]); @@ -3644,6 +3646,7 @@ int main(int argc, char **argv) ::arg().set("max-qperq", "Maximum outgoing queries per query")="50"; ::arg().set("max-total-msec", "Maximum total wall-clock time per query in milliseconds, 0 for unlimited")="7000"; ::arg().set("max-recursion-depth", "Maximum number of internal recursion calls per query, 0 for unlimited")="40"; + ::arg().set("max-udp-queries-per-round", "Maximum number of UDP queries processed per round, before returning back to normal processing")="10000"; ::arg().set("include-dir","Include *.conf files from this directory")=""; ::arg().set("security-poll-suffix","Domain name from which to query security update notifications")="secpoll.powerdns.com."; diff --git a/pdns/recursordist/docs/settings.rst b/pdns/recursordist/docs/settings.rst index ca19519dfb..8e2004e591 100644 --- a/pdns/recursordist/docs/settings.rst +++ b/pdns/recursordist/docs/settings.rst @@ -768,6 +768,18 @@ Maximum number of DNS queries in a TCP connection. Total maximum number of milliseconds of wallclock time the server may use to answer a single query. +.. _setting-max-udp-queries-per-round: + +``max-udp-queries-per-round`` +---------------------------------- +.. versionadded:: 4.2.0 + +- Integer +- Default: 10000 + +Maximum number of DNS queries processed in a single round after being woken up by the multiplexer, before +returning back to normal processing to handle other events. + .. _setting-minimum-ttl-override: ``minimum-ttl-override``