Available on crate feature
scaling only.Expand description
Scaling pressure calculation for autoscaler integration.
Produces a 0.0-100.0 composite metric based on weighted application signals with two hard gates (circuit breaker, memory pressure). Designed for KEDA but works with any autoscaler that reads Prometheus gauges.
§Architecture
App signals ──→ ScalingPressure ──→ {prefix}_scaling_pressure gauge
├─ Gate: circuit breaker open → 0.0
├─ Gate: memory ≥ threshold → 100.0
└─ Weighted composite → 0.0-100.0§Usage
- Define components with weights and saturation points
- Create
ScalingPressurewith base config + components - Update component values from your pipeline (lock-free)
- Call
calculate()when rendering Prometheus metrics
use hyperi_rustlib::scaling::{ScalingPressure, ScalingPressureConfig, ScalingComponent};
let pressure = ScalingPressure::new(
ScalingPressureConfig::default(),
vec![
ScalingComponent::new("kafka_lag", 0.35, 100_000.0),
ScalingComponent::new("buffer_depth", 0.25, 10_000.0),
ScalingComponent::new("memory", 0.40, 1.0),
],
);
// Update from pipeline (lock-free, call from any thread)
pressure.set_component("kafka_lag", 50_000.0);
pressure.set_memory(400_000_000, 1_000_000_000);
// Render in Prometheus endpoint
let value = pressure.calculate();
assert!(value >= 0.0 && value <= 100.0);§CPU Scaling
CPU is intentionally not included in the composite. KEDA’s native
CPU trigger reads from the Kubernetes metrics-server (container-level
CPU utilisation). Configure both triggers independently in your
KEDA ScaledObject:
scaling_pressuregauge → Prometheus scaler (app-level signals)- CPU utilisation → CPU scaler (container-level, via metrics-server)
KEDA scales to the MAX of all triggers.
Structs§
- Component
Snapshot - Per-component diagnostic snapshot.
- Pressure
Snapshot - Full diagnostic snapshot of scaling pressure state.
- Rate
Window - Sliding window rate calculator.
- Scaling
Component - Named scaling component with weight and saturation point.
- Scaling
Pressure - Lock-free scaling pressure calculator.
- Scaling
Pressure Config - Base configuration for scaling pressure calculation.
Enums§
- Gate
Type - Active gate preventing normal composite calculation.