From a22bc2d7d4974d730e4a7267d2f85e74db53c688 Mon Sep 17 00:00:00 2001 From: Artem Boldariev Date: Thu, 13 Feb 2025 15:05:10 +0200 Subject: [PATCH] DoH: change how the active streams number is calculated 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 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index afe5cce6da..2b7740d18a 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -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;