cluster/websocket: Make websocket dispatcher queue size configurable

Limit the number WebSocket events queued from external clients to
dispatcher instances to produce back pressure to the clients if
Zeek's IO loop is overloaded.
This commit is contained in:
Arne Welzel 2025-04-16 16:59:05 +02:00
parent 6bd624d9b2
commit 011029addc
9 changed files with 45 additions and 10 deletions

View file

@ -171,7 +171,13 @@ class ReplyMsgThread;
*/
class WebSocketEventDispatcher {
public:
WebSocketEventDispatcher();
/**
* Constructor.
*
* @param ident A string identifying this dispatcher instance. Used in metrics.
* @param queue_size Maximum queue size before events are stalled.
*/
WebSocketEventDispatcher(std::string ident, size_t queue_size);
~WebSocketEventDispatcher();
@ -295,12 +301,13 @@ struct ServerOptions {
int ping_interval_seconds = 5;
int max_connections = 100;
bool per_message_deflate = false;
size_t max_event_queue_size = 32;
struct TLSOptions tls_options;
bool operator==(const ServerOptions& o) const {
return host == o.host && port == o.port && ping_interval_seconds == o.ping_interval_seconds &&
max_connections == o.max_connections && per_message_deflate == o.per_message_deflate &&
tls_options == o.tls_options;
max_event_queue_size == o.max_event_queue_size && tls_options == o.tls_options;
}
};