<?xml version="1.0"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs),
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<?rfc tocappendix="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="3"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<?rfc comments="no" ?>
<?rfc inline="yes" ?>
<rfc category="exp" docName="draft-muks-dnsop-dns-thundering-herd-00" ipr="trust200902">

  <front>

    <title>The DNS thundering herd problem</title>

    <author fullname="Mukund Sivaraman" initials="M." surname="Sivaraman">
      <organization>Akira Systems Private Limited</organization>
      <address>
        <postal>
          <street>1 Coleman Street, #05-05 The Adelphi</street>
          <city>Singapore</city>
          <code>179803</code>
          <country>SG</country>
        </postal>
        <email>muks@akira.org</email>
        <uri>https://akira.org/</uri>
      </address>
    </author>

    <author fullname="Cricket Liu" surname="Liu">
      <organization>Infoblox</organization>
      <address>
        <postal>
          <street>3111 Coronado Drive</street>
          <city>Santa Clara</city>
          <code>95054</code>
          <country>US</country>
        </postal>
        <email>cricket@infoblox.com</email>
        <uri>http://www.infoblox.com/</uri>
      </address>
    </author>
    <date/>

    <!-- Meta-data Declarations -->

    <area>Operations and Management Area</area>
    <workgroup>Internet Engineering Task Force</workgroup>

    <!-- <keyword>dns</keyword> -->

    <abstract>
      <t>This document describes an observed regular pattern of spikes
      in queries that affects caching resolvers, and recommends
      software mitigations for it.</t>
    </abstract>

  </front>

  <middle>

    <section title="Problem Description">
      <t>Typically, DNS caching resolvers prepare answers for multiple
      clients from a single cached RRset <xref target="RFC1034"
      />. Depending on when in time the clients make their queries,
      caching resolvers reply with lower and lower valued TTLs, before
      the cached RRset from which answers are prepared expires. Clients
      themselves may cache and use their copies of RRsets until the TTL
      that the resolver replied with expires. A key property is that all
      these copies of answers, and the cached answer from which they are
      prepared, expire at the same absolute time.</t>

      <t>As an example, consider the following query sequence received
      by a resolver from 10 clients all querying for a popular
      www.example.org./A RRset. We use this example to illustrate two
      kinds of spikes in queries.</t>

      <!-- TBD: -->
      <!-- * There are many such thundering herds for many popular questions. -->
      <!-- * Some client applications appear to perform DNS lookups very frequently using API, and the resolver is queried the moment the answer expires within the application process. -->
      <!-- * This problem affects resolvers even at organizations, which are relatively private-access. -->
      <!-- * Low TTL RRsets increase the frequency of the problem, and make mitigation difficult. -->
      <!-- * Some implementations allow increasing TTL above very low authoritative answer TTLs, but this is controversial. -->

      <texttable>

        <ttcol>Client</ttcol>
        <ttcol>Query time (seconds since epoch)</ttcol>
        <ttcol>Answer RRset TTL</ttcol>
        <ttcol>Notes</ttcol>

        <c>C1</c>
        <c>1591441620</c>
        <c>600</c>
        <c>Answer was not found in cache. Resolver performs a resolution
        and caches authoritative answer with TTL=600.</c>

        <c>C2</c>
        <c>1591441626</c>
        <c>594</c>
        <c>Answered from cache.</c>

        <c>C3</c>
        <c>1591441713</c>
        <c>507</c>
        <c>Answered from cache.</c>

        <c>C4</c>
        <c>1591441780</c>
        <c>440</c>
        <c>Answered from cache.</c>

        <c>C5</c>
        <c>1591441866</c>
        <c>354</c>
        <c>Answered from cache.</c>

        <c>C6</c>
        <c>1591442006</c>
        <c>214</c>
        <c>Answered from cache.</c>

        <c>C7</c>
        <c>1591442070</c>
        <c>150</c>
        <c>Answered from cache.</c>

        <c>C8</c>
        <c>1591442070</c>
        <c>150</c>
        <c>Answered from cache.</c>

        <c>C9</c>
        <c>1591442213</c>
        <c>7</c>
        <c>Answered from cache.</c>

        <c>C3</c>
        <c>1591442220</c>
        <c>600</c>
        <c>Previously cached answer had expired in the resolver's
        cache. So the resolver performs a fresh resolution and caches
        authoritative answer with TTL=600.</c>

        <c>C5</c>
        <c>1591442220</c>
        <c>600</c>
        <c>Ditto if not joined with previous.</c>

        <c>C2</c>
        <c>1591442220</c>
        <c>600</c>
        <c>Ditto if not joined with previous.</c>

        <c>C6</c>
        <c>1591442220</c>
        <c>600</c>
        <c>Ditto if not joined with previous.</c>

        <c>C1</c>
        <c>1591442221</c>
        <c>599</c>
        <c>Answered from cache.</c>

        <c>C9</c>
        <c>1591442221</c>
        <c>599</c>
        <c>Answered from cache.</c>

        <c>C4</c>
        <c>1591442221</c>
        <c>599</c>
        <c>Answered from cache.</c>

        <c>C8</c>
        <c>1591442221</c>
        <c>599</c>
        <c>Answered from cache.</c>

        <c>C7</c>
        <c>1591442221</c>
        <c>599</c>
        <c>Answered from cache.</c>

        <c>C10</c>
        <c>1591442227</c>
        <c>593</c>
        <c>Answered from cache.</c>

        <c>C7</c>
        <c>1591442820</c>
        <c>600</c>
        <c>Previously cached answer had expired in the resolver's
        cache. So the resolver performs a fresh resolution and caches
        authoritative answer with TTL=600.</c>

        <c>C4</c>
        <c>1591442820</c>
        <c>600</c>
        <c>Ditto if not joined with previous.</c>

        <c>C1</c>
        <c>1591442820</c>
        <c>600</c>
        <c>Ditto if not joined with previous.</c>

        <c>C2</c>
        <c>1591442820</c>
        <c>600</c>
        <c>Ditto if not joined with previous.</c>

        <c>C10</c>
        <c>1591442820</c>
        <c>600</c>
        <c>Ditto if not joined with previous.</c>

        <c>C8</c>
        <c>1591442820</c>
        <c>600</c>
        <c>Ditto if not joined with previous.</c>

        <c>C3</c>
        <c>1591442821</c>
        <c>599</c>
        <c>Answered from cache.</c>

        <c>C9</c>
        <c>1591442821</c>
        <c>599</c>
        <c>Answered from cache.</c>

        <c>C5</c>
        <c>1591442821</c>
        <c>599</c>
        <c>Answered from cache.</c>

        <c>C6</c>
        <c>1591442821</c>
        <c>599</c>
        <c>Answered from cache.</c>

      </texttable>

    </section>

    <section title="Requirements Notation">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
      NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
      "MAY", and "OPTIONAL" in this document are to be interpreted as
      described in <xref target="RFC2119"/> <xref target="RFC8174"/>
      when, and only when, they appear in all capitals, as shown
      here.</t>
    </section>

    <section title="Mitigations">

      <section title="Combine identical queries to upstream nameservers">
        <t>At a resolver, when multiple queries have arrived together
        asking the same question and there is no existing unexpired
        cached answer, DNS resolutions have to be performed to answer
        these queries. De-duplication of these multiple resolutions into
        a single DNS resolution by the resolver is RECOMMENDED where
        possible.</t>

        <t>If such de-duplication is not performed, the client queries
        will effectively be forwarded 1:1 by the resolver to upstream
        nameservers, and they will significantly increase the upstream
        nameservers' query rate in spikes. Some nameserver operators may
        have deployed measures such as response rate limiting <xref
        target="RRL" /> and other IP-address based rate limiting, which
        may cause them to deny service to the resolver due to the query
        spikes of identical queries.</t>

      </section>

      <section title="Include noise in response TTLs from caching resolvers">
        <t>Caching resolvers are permitted to lower the TTLs of RRsets
        in their answers as they please <xref target="RFC2181"/>. This
        can be used to distribute the time at which RRset copies
        received by clients expire from a single absolute time to a time
        interval. However, this has to be done with some consideration
        such that the thundering herd doesn't re-converge at the expiry
        time of the cached RRset that is used to generate answers to the
        clients.</t>

	<t>TBD.</t>
      </section>

      <section title="Other mitigations">
        <t>With very low authoritative RRset TTLs (such as under 60s)
        for popular questions, the frequency of the thundering herd
        increases and including noise in response TTLs is less effective
        because the maximum TTL to work with is low. In other words,
        there is a shorter interval over which the thundering herd can
        be distributed by adding noise. Some implementations permit an
        operator to set a minimum TTL value such that authoritative
        RRset TTLs with lower values are increased and clamped to the
        minimum TTL value. This breaks currently accepted DNS protocol,
        and hence this document does not make any recommendation about
        it.</t>
      </section>

    </section>

    <section title="Security Considerations">
      <t>There are no security considerations.</t>
    </section>

    <section title="IANA considerations">
      <t>There are no IANA considerations.</t>
    </section>

    <section title="Acknowledgements">
      <t>This document was prepared from thundering herd client query
      patterns noticed at resolvers of ISPs and large institutions,
      which resulted in traffic spikes that caused performance issues
      and lookup failures. The authors acknowledge the contribution of
      Ramesh Damodaran who participated in analysis of these
      patterns.</t>
    </section>

  </middle>

  <back>

    <references title="Normative references">
      <?rfc include="reference.RFC.1034.xml"?>
      <?rfc include="reference.RFC.2119.xml"?>
      <?rfc include="reference.RFC.2181.xml"?>
      <?rfc include="reference.RFC.8174.xml"?>
    </references>

    <references title="Informative references">
      <reference anchor="RRL" target="https://ftp.isc.org/isc/pubs/tn/isc-tn-2012-1.txt">
	<front>
	  <title>DNS Response Rate Limiting (DNS RRL)</title>
	  <author fullname="Paul Vixie"  initials="P." surname="Vixie"></author>
	  <author fullname="Vernon Schryver"  initials="V." surname="Schryver"></author>
	  <date year="2012" />
	</front>
      </reference>
    </references>

    <section title="Change history (to be removed before publication)">
      <t>
        <list style="symbols">

          <t>
          draft-muks-dnsop-dns-thundering-herd-00
          <vspace/>
          * Initial draft.
          </t>

        </list>
      </t>
    </section>

  </back>
</rfc>
