]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] increase and allow configuration of lwresd tasks/clients
authorEvan Hunt <each@isc.org>
Fri, 16 May 2014 05:01:19 +0000 (22:01 -0700)
committerEvan Hunt <each@isc.org>
Fri, 16 May 2014 05:01:19 +0000 (22:01 -0700)
3852. [func] Increase the default number of clients available
for servicing lightweight resolver queries, and
make them configurable via the "lwres-tasks" and
"lwres-clients" options.  (Thanks to Tomas Hozza.)
[RT #35857]

CHANGES
bin/named/include/named/lwresd.h
bin/named/lwresd.c
bin/named/named.conf.docbook
doc/arm/Bv9ARM-book.xml
lib/isccfg/namedconf.c

diff --git a/CHANGES b/CHANGES
index 8e72464d45ddf9bd2b3578252978abd4ae0cd16d..65269b7deb8cb3946fd4f2f2a1b984a4fce12aaa 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+3852.  [func]          Increase the default number of clients available
+                       for servicing lightweight resolver queries, and
+                       make them configurable via the "lwres-tasks" and
+                       "lwres-clients" options.  (Thanks to Tomas Hozza.)
+                       [RT #35857]
+
 3851.  [func]          Allow libseccomp based system-call filtering
                        on Linux; use "configure --enable-seccomp" to
                        turn it on.  Thanks to Loganaden Velvindron for
index 565e58d7abf9282115c48a464d35bae290d09d2a..f5cef7b7bf2092bc8854cd6bdc1c14241d284cb1 100644 (file)
@@ -36,6 +36,8 @@ struct ns_lwresd {
        dns_view_t *view;
        ns_lwsearchlist_t *search;
        unsigned int ndots;
+       unsigned int ntasks;
+       unsigned int nclients;
        isc_mem_t *mctx;
        isc_boolean_t shutting_down;
        unsigned int refs;
index 8a9ecb64afb3d092191dfd781667dd2431bef420..84eb593507ecb72885bfc28d4e8baedf4f494837 100644 (file)
 #define LWRESLISTENER_MAGIC    ISC_MAGIC('L', 'W', 'R', 'L')
 #define VALID_LWRESLISTENER(l) ISC_MAGIC_VALID(l, LWRESLISTENER_MAGIC)
 
-/*!
- * The total number of clients we can handle will be NTASKS * NRECVS.
- */
-#define NTASKS         2       /*%< tasks to create to handle lwres queries */
-#define NRECVS         2       /*%< max clients per task */
+#define LWRESD_NCLIENTS_MAX            32768   /*%< max clients per task */
 
 typedef ISC_LIST(ns_lwreslistener_t) ns_lwreslistenerlist_t;
 
@@ -395,6 +391,24 @@ ns_lwdmanager_create(isc_mem_t *mctx, const cfg_obj_t *lwres,
                }
        }
 
+       obj = NULL;
+       (void)cfg_map_get(lwres, "lwres-tasks", &obj);
+       if (obj != NULL)
+               lwresd->ntasks = cfg_obj_asuint32(obj);
+       else
+               lwresd->ntasks = ns_g_cpus;
+
+       obj = NULL;
+       (void)cfg_map_get(lwres, "lwres-clients", &obj);
+       if (obj != NULL) {
+               lwresd->nclients = cfg_obj_asuint32(obj);
+               if (lwresd->nclients > LWRESD_NCLIENTS_MAX)
+                       lwresd->nclients = LWRESD_NCLIENTS_MAX;
+       } else if (ns_g_lwresdonly)
+               lwresd->nclients = 1024;
+       else
+               lwresd->nclients = 256;
+
        lwresd->magic = LWRESD_MAGIC;
 
        *lwresdp = lwresd;
@@ -604,15 +618,24 @@ static isc_result_t
 listener_startclients(ns_lwreslistener_t *listener) {
        ns_lwdclientmgr_t *cm;
        unsigned int i;
-       isc_result_t result;
+       isc_result_t result = ISC_R_SUCCESS;
+
+       isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
+                     NS_LOGMODULE_LWRESD, ISC_LOG_DEBUG(6),
+                     "listener_startclients: creating %d "
+                     "managers with %d clients each",
+                     listener->manager->ntasks, listener->manager->nclients);
 
        /*
         * Create the client managers.
         */
-       result = ISC_R_SUCCESS;
-       for (i = 0; i < NTASKS && result == ISC_R_SUCCESS; i++)
-               result = ns_lwdclientmgr_create(listener, NRECVS,
+       for (i = 0; i < listener->manager->ntasks; i++) {
+               result = ns_lwdclientmgr_create(listener,
+                                               listener->manager->nclients,
                                                ns_g_taskmgr);
+               if (result != ISC_R_SUCCESS)
+                       break;
+       }
 
        /*
         * Ensure that we have created at least one.
index 4c99a61ecd7af8aaf3c876036a71eb53703dfbe4..cf3d9499b2ca33c93dccbc4bc6751011d2ed3c8e 100644 (file)
@@ -187,6 +187,8 @@ lwres {
        view <replaceable>string</replaceable> <replaceable>optional_class</replaceable>;
        search { <replaceable>string</replaceable>; ... };
        ndots <replaceable>integer</replaceable>;
+       lwres-tasks <replaceable>integer</replaceable>;
+       lwres-clients <replaceable>integer</replaceable>;
 };
 </literallayout>
   </refsect1>
index aa0b4b229029f6244327f3c66dc7b9d95fd6f13f..b0b691790da7aeb3327b4744d6e89ad8e14166cf 100644 (file)
@@ -2563,7 +2563,12 @@ $ORIGIN 0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
        be configured to act as a lightweight resolver daemon using the
        <command>lwres</command> statement in <filename>named.conf</filename>.
       </para>
-
+      <para>
+        The number of client queries that the <command>lwresd</command>
+        daemon is able to serve can be set using the
+        <option>lwres-tasks</option> and <option>lwres-clients</option> 
+        statements in the configuration.
+      </para>
     </sect1>
   </chapter>
 
@@ -4654,6 +4659,8 @@ badresp:1,adberr:0,findfail:0,valfail:0]
     <optional> view <replaceable>view_name</replaceable>; </optional>
     <optional> search { <replaceable>domain_name</replaceable> ; <optional> <replaceable>domain_name</replaceable> ; ... </optional> }; </optional>
     <optional> ndots <replaceable>number</replaceable>; </optional>
+    <optional> lwres-tasks <replaceable>number</replaceable>; </optional>
+    <optional> lwres-clients <replaceable>number</replaceable>; </optional>
 };
 </programlisting>
 
@@ -4711,7 +4718,32 @@ badresp:1,adberr:0,findfail:0,valfail:0]
          minimum
          number of dots in a relative domain name that should result in an
          exact match lookup before search path elements are appended.
-       </para>
+        </para>
+        <para>
+          The <option>lwres-tasks</option> statement specifies the number
+          of worker threads the lightweight resolver will dedicate to serving
+          clients.  By default the number is the same as the number of CPUs on
+          the system; this can be overridden using the <option>-n</option>
+          command line option when starting the server. 
+        </para>
+        <para>
+          The <option>lwres-clients</option> specifies
+          the number of client objects per thread the lightweight
+          resolver should create to serve client queries.
+          By default, if the lightweight resolver runs as a part
+          of <command>named</command>, 256 client objects are
+          created for each task; if it runs as <command>lwresd</command>,
+          1024 client objects are created for each thread. The maximum
+          value is 32768; higher values will be silently ignored and
+          the maximum will be used instead.
+          Note that setting too high a value may overconsume
+          system resources.
+        </para>
+        <para>
+          The maximum number of client queries that the lightweight
+          resolver can handle at any one time equals
+          <option>lwres-tasks</option> times <option>lwres-clients</option>.
+        </para>
       </sect2>
       <sect2>
        <title><command>masters</command> Statement Grammar</title>
index cd5be199dd47abe1664ebfb6d03e619b8a52fc68..96ce6c12df3a0c9e3c403deebff7d82eaf28036d 100644 (file)
@@ -2925,6 +2925,8 @@ lwres_clauses[] = {
        { "view", &cfg_type_lwres_view, 0 },
        { "search", &cfg_type_lwres_searchlist, 0 },
        { "ndots", &cfg_type_uint32, 0 },
+       { "lwres-tasks", &cfg_type_uint32, 0},
+       { "lwres-clients", &cfg_type_uint32, 0},
        { NULL, NULL, 0 }
 };