fix: harden Redis client timeouts and correct userid column bugs

Redis client had a 35s worst-case stall (10s read/write timeout x3
retries) on a single call, which under concurrent load exhausted the
connection pool and cascaded into a full outage. Timeouts and retries
are now tight enough that a degraded Redis fails fast instead of
tying up pooled connections.

Also fixes two userid/appuserid column mix-ups in delivery queries
(deliveryController.go, domain/delivery.go) and points the Dockerfile
build at main.go explicitly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Suriya
2026-07-20 20:40:35 +05:30
parent 588f27b917
commit 36eb8cd194
4 changed files with 18 additions and 13 deletions

View File

@@ -183,18 +183,23 @@ func InitRedis() {
DB: 0,
// ✅ TIMEOUTS (VERY IMPORTANT)
DialTimeout: 10 * time.Second,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
// Kept short so a slow/degraded Redis fails fast instead of tying up a
// pooled connection for tens of seconds. A previous config (10s x3 retries)
// let a single stuck call hold a connection for ~35s, which under concurrent
// load exhausted the pool and cascaded into a cluster-wide outage.
DialTimeout: 5 * time.Second,
ReadTimeout: 3 * time.Second,
WriteTimeout: 3 * time.Second,
// ✅ POOL
PoolSize: 50,
MinIdleConns: 10,
PoolTimeout: 4 * time.Second,
// ✅ RETRIES
MaxRetries: 3,
MinRetryBackoff: 500 * time.Millisecond,
MaxRetryBackoff: 2 * time.Second,
MaxRetries: 1,
MinRetryBackoff: 100 * time.Millisecond,
MaxRetryBackoff: 500 * time.Millisecond,
})
maxRetries := 5