pub struct PoolPressureMonitorConfig {
pub enabled: bool,
pub min_pool_size: u32,
pub max_pool_size: u32,
pub target_queue_depth: u32,
pub scale_up_step: u32,
pub scale_down_step: u32,
pub scale_down_idle_ratio: f64,
pub tuning_interval_ms: u64,
pub samples_before_action: u32,
}Expand description
Configuration for connection pool pressure monitoring with scaling recommendations.
This monitor samples PoolMetrics at a configurable interval and emits
scaling recommendations via fraiseql_pool_tuning_* Prometheus metrics and
log lines. It does not resize the pool at runtime — the underlying
deadpool-postgres library does not expose a resize() API.
To act on recommendations: adjust max_connections in fraiseql.toml and
restart the server. Active pool resizing is tracked as future work (migration
to bb8 with resize() support).
§Recommendation mode
All scaling decisions are advisory. When a recommendation fires, the monitor:
- Updates
fraiseql_pool_tuning_adjustments_total(Prometheus counter) - Logs the recommendation at
WARNlevel - Updates
recommended_size()for external inspection
To suppress the WARN noise in environments that already tune the pool
manually, set enabled = false in [pool_tuning].
Fields§
§enabled: boolEnable adaptive pool sizing. Default: false.
min_pool_size: u32Minimum pool size. The tuner never shrinks below this value. Default: 5.
max_pool_size: u32Maximum pool size. The tuner never grows above this value. Default: 50.
target_queue_depth: u32Maximum acceptable queue depth before scaling up. Default: 3.
scale_up_step: u32Connections to add per scale-up step. Default: 5.
scale_down_step: u32Connections to remove per scale-down step. Default: 2.
scale_down_idle_ratio: f64Minimum idle ratio (idle / total) before considering a scale-down. Default: 0.5 (50% idle connections triggers potential shrink).
tuning_interval_ms: u64Polling interval in milliseconds. Default: 30 000 (30 s).
samples_before_action: u32Consecutive samples above threshold required before acting. Default: 3.
Implementations§
Trait Implementations§
Source§impl Clone for PoolPressureMonitorConfig
impl Clone for PoolPressureMonitorConfig
Source§fn clone(&self) -> PoolPressureMonitorConfig
fn clone(&self) -> PoolPressureMonitorConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PoolPressureMonitorConfig
impl Debug for PoolPressureMonitorConfig
Source§impl Default for PoolPressureMonitorConfig
impl Default for PoolPressureMonitorConfig
Source§impl<'de> Deserialize<'de> for PoolPressureMonitorConfig
impl<'de> Deserialize<'de> for PoolPressureMonitorConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for PoolPressureMonitorConfig
impl RefUnwindSafe for PoolPressureMonitorConfig
impl Send for PoolPressureMonitorConfig
impl Sync for PoolPressureMonitorConfig
impl Unpin for PoolPressureMonitorConfig
impl UnsafeUnpin for PoolPressureMonitorConfig
impl UnwindSafe for PoolPressureMonitorConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more