This commit adds a new per-backend config setting `max_udp_outstanding`
which overrides the global `tuning.udp.max_outstanding_per_backend`
setting.
If the per-backend `max_udp_outstanding` setting is omitted, the value
of the global option `tuning.udp.max_outstanding_per_backend` will be
used instead.
This allows tuning the number of UDP states allocated on a per-backend
basis in order to tune the amount of memory consumed by dnsdist.
Low-latency backends may only need a small number of UDP states, while
high-latency backends may need a higher number of UDP states.
The `tuning.udp.max_outstanding_per_backend` setting and the new
per-backend `max_udp_outstanding` setting directly control the sizes of
the vectors of `IDState` objects that are preallocated at startup.
The size of the `IDState` object can vary depending on compile time
options, but in my local build it is currently 496 bytes. This means
that a backend with the maximum number of UDP states (65535) will
require allocating at least (496 * 65535 /
1048576) = 31 MB. Similarly,
a backend with 8192 UDP states will require allocating 3.9 MB, and a
backend with 256 UDP states only requires 124 KB.
Signed-off-by: Robert Edmonds <edmonds@users.noreply.github.com>
idStates.clear();
}
else {
- idStates.resize(config.d_maxUDPOutstanding);
+ const auto maxUDPOutstanding = d_config.d_maxUDPOutstanding > 0 ? d_config.d_maxUDPOutstanding : config.d_maxUDPOutstanding;
+ idStates.resize(maxUDPOutstanding);
}
sockets.resize(d_config.d_numberOfSockets);
backendConfig.order = config.order;
backendConfig.d_weight = config.weight;
backendConfig.d_maxInFlightQueriesPerConn = config.max_in_flight;
+ backendConfig.d_maxUDPOutstanding = config.max_udp_outstanding;
backendConfig.d_tcpConcurrentConnectionsLimit = config.max_concurrent_tcp_connections;
backendConfig.name = std::string(config.name);
if (!config.id.empty()) {
type: "u32"
default: "1"
description: "Maximum number of in-flight queries. The default is 0, which disables out-of-order processing. It should only be enabled if the backend does support out-of-order processing. Out-of-order processing needs to be enabled on the frontend as well"
+ - name: "max_udp_outstanding"
+ type: "u32"
+ default: "0"
+ description: "Maximum number of outstanding UDP queries for this backend. If not set, defaults to ``tuning.udp.max_outstanding_per_backend``."
- name: "tcp_only"
type: "bool"
default: "false"
#endif /* HAVE_XSK */
size_t d_numberOfSockets{1};
size_t d_maxInFlightQueriesPerConn{1};
+ size_t d_maxUDPOutstanding{0};
size_t d_tcpConcurrentConnectionsLimit{0};
int order{1};
int d_weight{1};