From a244043e12cbdd165b71976e476a63b60a0a0f46 Mon Sep 17 00:00:00 2001 From: master <> Date: Thu, 2 Apr 2026 12:23:55 +0300 Subject: [PATCH] Tune Valkey poll: 10-30s window (fits within 60s gateway timeout) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QueueWaitTimeoutSeconds: 5 → 10 (base) Randomization: [base, 2×base] → [base, 3×base] = random 10-30s When Pub/Sub is alive: instant delivery (no change). When Pub/Sub is dead: consumer wakes in 10-30s via semaphore timeout, reads pending + new messages. 30s worst case < 60s gateway timeout. Load: 30 services × 1 poll per random(10-30s) = ~1.5 polls/sec. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Options/ValkeyTransportOptions.cs | 2 +- .../StellaOps.Messaging.Transport.Valkey/ValkeyMessageQueue.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Router/__Libraries/StellaOps.Messaging.Transport.Valkey/Options/ValkeyTransportOptions.cs b/src/Router/__Libraries/StellaOps.Messaging.Transport.Valkey/Options/ValkeyTransportOptions.cs index 6aa27d7aa..ed96244f5 100644 --- a/src/Router/__Libraries/StellaOps.Messaging.Transport.Valkey/Options/ValkeyTransportOptions.cs +++ b/src/Router/__Libraries/StellaOps.Messaging.Transport.Valkey/Options/ValkeyTransportOptions.cs @@ -53,5 +53,5 @@ public class ValkeyTransportOptions /// Configurable via compose env var VALKEY_QUEUE_WAIT_TIMEOUT. /// /// - public int QueueWaitTimeoutSeconds { get; set; } = 5; + public int QueueWaitTimeoutSeconds { get; set; } = 10; } diff --git a/src/Router/__Libraries/StellaOps.Messaging.Transport.Valkey/ValkeyMessageQueue.cs b/src/Router/__Libraries/StellaOps.Messaging.Transport.Valkey/ValkeyMessageQueue.cs index 045eee07a..74e9bfeb6 100644 --- a/src/Router/__Libraries/StellaOps.Messaging.Transport.Valkey/ValkeyMessageQueue.cs +++ b/src/Router/__Libraries/StellaOps.Messaging.Transport.Valkey/ValkeyMessageQueue.cs @@ -468,7 +468,7 @@ public sealed class ValkeyMessageQueue : IMessageQueue, INot var configuredSeconds = _transportOptions.QueueWaitTimeoutSeconds; var effectiveTimeout = configuredSeconds <= 0 ? Timeout.InfiniteTimeSpan - : TimeSpan.FromSeconds(configuredSeconds + Random.Shared.Next(0, configuredSeconds)); + : TimeSpan.FromSeconds(configuredSeconds + Random.Shared.Next(0, 2 * configuredSeconds)); // Wait for a pub/sub signal or timeout (fallback for missed notifications). try