Skip to content

Commit

Permalink
ref(redis): Set minimum redis pool size (#3822)
Browse files Browse the repository at this point in the history
We should have a minimum for small setups with almost no cores, I choose
our previous default as the new minimum.
  • Loading branch information
Dav1dde authored Jul 16, 2024
1 parent b561ec3 commit 46a5a35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion relay-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,8 @@ impl Config {
max_connections: redis
.options
.max_connections
.unwrap_or(cpu_concurrency as u32 * 2),
.unwrap_or(cpu_concurrency as u32 * 2)
.min(crate::redis::DEFAULT_MIN_MAX_CONNECTIONS),
connection_timeout: redis.options.connection_timeout,
max_lifetime: redis.options.max_lifetime,
idle_timeout: redis.options.idle_timeout,
Expand Down
6 changes: 5 additions & 1 deletion relay-config/src/redis.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use serde::{Deserialize, Serialize};

/// For small setups, `2 x limits.max_thread_count` does not leave enough headroom.
/// In this case, we fall back to the old default.
pub(crate) const DEFAULT_MIN_MAX_CONNECTIONS: u32 = 24;

/// Additional configuration options for a redis client.
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
#[serde(default)]
pub struct PartialRedisConfigOptions {
/// Maximum number of connections managed by the pool.
///
/// Defaults to 2x `limits.max_thread_count`.
/// Defaults to 2x `limits.max_thread_count` or a minimum of 24.
#[serde(skip_serializing_if = "Option::is_none")]
pub max_connections: Option<u32>,
/// Sets the connection timeout used by the pool, in seconds.
Expand Down

0 comments on commit 46a5a35

Please sign in to comment.