diff --git a/lib/pools/src/lib.rs b/lib/pools/src/lib.rs index fe6376936c..789a83f631 100644 --- a/lib/pools/src/lib.rs +++ b/lib/pools/src/lib.rs @@ -146,7 +146,7 @@ async fn crdb_from_env(_client_name: String) -> Result, Error> // Increase lifetime to mitigate: https://github.com/launchbadge/sqlx/issues/2854 // // See max lifetime https://www.cockroachlabs.com/docs/stable/connection-pooling#set-the-maximum-lifetime-of-connections - .max_lifetime(Duration::from_secs(30 * 60)) + .max_lifetime(Duration::from_secs(15 * 60)) // Remove connections after a while in order to reduce load // on CRDB after bursts .idle_timeout(Some(Duration::from_secs(3 * 60))) diff --git a/lib/pools/src/utils/sql_query_macros.rs b/lib/pools/src/utils/sql_query_macros.rs index 2c94e2b974..0ea5f3f93a 100644 --- a/lib/pools/src/utils/sql_query_macros.rs +++ b/lib/pools/src/utils/sql_query_macros.rs @@ -6,10 +6,10 @@ lazy_static::lazy_static! { governor::clock::DefaultClock, governor::middleware::NoOpMiddleware > = governor::RateLimiter::direct( - // Limit how many connections can be created to the database - governor::Quota::per_second(std::num::NonZeroU32::new(10).unwrap()) - // Allow creating at most 5 connections at the same time - .allow_burst(std::num::NonZeroU32::new(5).unwrap()) + // Limit how fast the pool size can grow in order to encourage reusuing existing + // connections instead of opening new ones. + governor::Quota::per_minute(std::num::NonZeroU32::new(10 * 60).unwrap()) + .allow_burst(std::num::NonZeroU32::new(500).unwrap()) ); } diff --git a/svc/pkg/cluster/standalone/default-update/src/lib.rs b/svc/pkg/cluster/standalone/default-update/src/lib.rs index f0a3e4e2c2..59cc690823 100644 --- a/svc/pkg/cluster/standalone/default-update/src/lib.rs +++ b/svc/pkg/cluster/standalone/default-update/src/lib.rs @@ -186,8 +186,8 @@ pub async fn run_from_env(use_autoscaler: bool) -> GlobalResult<()> { .into_iter() .map(|(pool_type, pool)| { let desired_count = match pool_type { - PoolType::Ats => Some(pool.desired_count), - PoolType::Job | PoolType::Gg => { + PoolType::Ats | PoolType::Gg => Some(pool.desired_count), + PoolType::Job => { if use_autoscaler { None } else {