Increase maxRetriesPerRequest for Redis connections to improve resilience

This commit is contained in:
Owen
2026-09-02 11:57:50 -04:00
parent e0937a3afa
commit 49d5b0ec34
+8 -6
View File
@@ -158,7 +158,7 @@ class RedisManager {
this.writeClient = new Redis({ this.writeClient = new Redis({
...masterConfig, ...masterConfig,
enableReadyCheck: false, enableReadyCheck: false,
maxRetriesPerRequest: 3, maxRetriesPerRequest: 50,
keepAlive: 30000, keepAlive: 30000,
connectTimeout: this.connectionTimeout, connectTimeout: this.connectionTimeout,
commandTimeout: this.commandTimeout commandTimeout: this.commandTimeout
@@ -169,7 +169,7 @@ class RedisManager {
this.readClient = new Redis({ this.readClient = new Redis({
...replicaConfig!, ...replicaConfig!,
enableReadyCheck: false, enableReadyCheck: false,
maxRetriesPerRequest: 3, maxRetriesPerRequest: 50,
keepAlive: 30000, keepAlive: 30000,
connectTimeout: this.connectionTimeout, connectTimeout: this.connectionTimeout,
commandTimeout: this.commandTimeout commandTimeout: this.commandTimeout
@@ -186,7 +186,7 @@ class RedisManager {
this.publisher = new Redis({ this.publisher = new Redis({
...masterConfig, ...masterConfig,
enableReadyCheck: false, enableReadyCheck: false,
maxRetriesPerRequest: 3, maxRetriesPerRequest: 50,
keepAlive: 30000, keepAlive: 30000,
connectTimeout: this.connectionTimeout, connectTimeout: this.connectionTimeout,
commandTimeout: this.commandTimeout commandTimeout: this.commandTimeout
@@ -196,7 +196,7 @@ class RedisManager {
this.subscriber = new Redis({ this.subscriber = new Redis({
...(this.hasReplicas ? replicaConfig! : masterConfig), ...(this.hasReplicas ? replicaConfig! : masterConfig),
enableReadyCheck: false, enableReadyCheck: false,
maxRetriesPerRequest: 3, maxRetriesPerRequest: 50,
keepAlive: 30000, keepAlive: 30000,
connectTimeout: this.connectionTimeout, connectTimeout: this.connectionTimeout,
commandTimeout: this.commandTimeout commandTimeout: this.commandTimeout
@@ -901,7 +901,9 @@ class RegionalRedisManager {
// if the configured host doesn't match that pattern (e.g. local dev), // if the configured host doesn't match that pattern (e.g. local dev),
// in which case callers should fall back to the primary for reads. // in which case callers should fall back to the primary for reads.
private getReplicaHost(primaryHost: string): string | null { private getReplicaHost(primaryHost: string): string | null {
const match = primaryHost.match(/^redis\.([^.]+)\.svc\.cluster\.local$/); const match = primaryHost.match(
/^redis\.([^.]+)\.svc\.cluster\.local$/
);
if (!match) return null; if (!match) return null;
const namespace = match[1]; const namespace = match[1];
return `redis-1.redis-headless.${namespace}.svc.cluster.local`; return `redis-1.redis-headless.${namespace}.svc.cluster.local`;
@@ -912,7 +914,7 @@ class RegionalRedisManager {
const baseOpts = { const baseOpts = {
...cfg, ...cfg,
enableReadyCheck: false, enableReadyCheck: false,
maxRetriesPerRequest: 3, maxRetriesPerRequest: 50,
keepAlive: 10000, keepAlive: 10000,
connectTimeout: this.connectionTimeout, connectTimeout: this.connectionTimeout,
commandTimeout: this.commandTimeout commandTimeout: this.commandTimeout