]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
DoH: change how the active streams number is calculated
authorArtem Boldariev <artem@boldariev.com>
Thu, 13 Feb 2025 13:05:10 +0000 (15:05 +0200)
committerArtem Boldariev <artem@boldariev.com>
Wed, 19 Feb 2025 15:52:36 +0000 (17:52 +0200)
This commit changes the way how the number of active HTTP streams is
calculated and allows it to scale with the values of the maximum
amount of streams per connection, instead of effectively capping at
STREAM_CLIENTS_PER_CONN.

The original limit, which is intended to define the pipelining limit
for TCP/DoT. However, it appeared to be too restrictive for DoH, as it
works quite differently and implements pipelining at protocol level by
the means of multiplexing multiple streams. That renders each stream
to be effectively a separate connection from the point of view of the
rest of the codebase.

lib/isc/netmgr/http.c

index afe5cce6daf818126855734b00991327dea31c70..2b7740d18a836511622f317436434aa2c9cd5e41 100644 (file)
@@ -1539,9 +1539,21 @@ nothing_to_send:
 static inline bool
 http_too_many_active_streams(isc_nm_http_session_t *session) {
        const uint64_t active_streams = session->received - session->processed;
+       /*
+        * The motivation behind capping the maximum active streams number
+        * to a third of maximum streams is to allow the value to scale
+        * with the max number of streams.
+        *
+        * We do not want to have too many active streams at once as every
+        * stream is processed as a separate virtual connection by the
+        * higher level code. If a client sends a bulk of requests without
+        * waiting for the previous ones to complete we might want to
+        * throttle it as it might be not a friend knocking at the
+        * door. We already have some job to do for it.
+        */
        const uint64_t max_active_streams =
-               ISC_MIN(ISC_NETMGR_MAX_STREAM_CLIENTS_PER_CONN,
-                       session->max_concurrent_streams);
+               ISC_MAX(ISC_NETMGR_MAX_STREAM_CLIENTS_PER_CONN,
+                       session->max_concurrent_streams / 3);
 
        if (session->client) {
                return false;