mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-12 18:04:29 +01:00
Add max redis response time for reads
This commit is contained in:
parent
d28ac39d4f
commit
7678be1e24
3 changed files with 8 additions and 0 deletions
|
@ -165,6 +165,7 @@ addDefaults(config, {
|
||||||
commandsQueueMaxLength: 3000,
|
commandsQueueMaxLength: 3000,
|
||||||
stopWritingAfterResponseTime: 50,
|
stopWritingAfterResponseTime: 50,
|
||||||
responseTimePause: 1000,
|
responseTimePause: 1000,
|
||||||
|
maxReadResponseTime: 500,
|
||||||
disableHashCache: false,
|
disableHashCache: false,
|
||||||
clientCacheSize: 2000,
|
clientCacheSize: 2000,
|
||||||
useCompression: false,
|
useCompression: false,
|
||||||
|
|
|
@ -10,6 +10,7 @@ interface RedisConfig extends redis.RedisClientOptions {
|
||||||
maxWriteConnections: number;
|
maxWriteConnections: number;
|
||||||
stopWritingAfterResponseTime: number;
|
stopWritingAfterResponseTime: number;
|
||||||
responseTimePause: number;
|
responseTimePause: number;
|
||||||
|
maxReadResponseTime: number;
|
||||||
disableHashCache: boolean;
|
disableHashCache: boolean;
|
||||||
clientCacheSize: number;
|
clientCacheSize: number;
|
||||||
useCompression: boolean;
|
useCompression: boolean;
|
||||||
|
|
|
@ -222,6 +222,12 @@ if (config.redis?.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.redis.maxReadResponseTime && activeRequests > maxStoredTimes
|
||||||
|
&& readResponseTime[readResponseTime.length - 1] > config.redis.maxReadResponseTime) {
|
||||||
|
reject(new TooManyActiveConnectionsError(`Redis response time too high in general: ${readResponseTime[readResponseTime.length - 1]}ms with ${activeRequests} connections`));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// For tracking
|
// For tracking
|
||||||
if (!shouldClientCacheKey(key)) memoryCacheUncachedMisses++;
|
if (!shouldClientCacheKey(key)) memoryCacheUncachedMisses++;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue