Skip to Content

Policies

ScaleOps Replicas Optimization uses policies to control how HPA workloads are optimized. Policies define the strategy for setting minimum replicas, prediction behavior, and optimization thresholds.

HPA Policy

General

  • Min Replicas - set the minimum replicas recommendation strategy and boundary.

    • Min replicas strategy:
      • Set history based for all workloads - Use the historical data to set the min replicas for all workloads.
      • Set history based for predictable workloads - Use the historical data to set the min replicas for predictable workloads. Static workloads will keep the original HPA min replicas value when selecting this option.
      • Set history based for static workloads - Use the historical data to set the min replicas for static workloads. Predictable workloads will keep the original HPA min replicas value when selecting this option.
      • Set min replicas for all workloads - Set a constant min replicas for all workloads assigned with the policy.
      • Keep min replicas for all workloads - Use the original HPA min replicas value for all workloads. This option enables the use of prediction ahead of time scaling inclusively, without using the min-replica recommendation. Note that the defined boundary is respected when using this option.
    • Min replica boundary - Ensure that the min replicas are not set below the defined value.
    • Min replicas headroom - Add a safety buffer to your minimum replicas. This helps ensure you have extra capacity for unexpected traffic spikes. Applies to both predictable and static workloads. Advanced users can set different values for each workload type by editing the policy custom resource, with the UI showing predictable workload values if they differ. Available in v1.15.4+
  • Max replicas - Set the maximum amount of replicas.

  • Required history for optimization - HPA optimization will be applied after gathering the minimum required historical data.

Predictable Workloads

  • Prediction - By enabling prediction, ScaleOps identifies workloads as predictable, and increase the amount of replicas ahead of the predicted peak.
    • Look ahead duration - Set the duration to look ahead for the prediction.
  • Min Replicas - For workloads identified as predictable, select the desired percentile from historical usage data to determine the minimum number of replicas. It is recommended to use the 80th percentile to take full advantage of the prediction feature and maximize cost savings. Note that this option can be disabled, based on the selected strategy on the General tab.

Static Workloads

  • Min Replicas - For static workloads, select the desired percentile from historical replicas data to determine the minimum number of replicas. Note that this option can be disabled, based on the selected strategy on the General tab.

Threshold (beta)
Available in v1.30.18+

The Threshold tab controls Replica Threshold Optimization. It optimizes HPA CPU utilization thresholds based on historical workload behavior to reduce over-scaling and improve efficiency.

  • Enable threshold optimization — Turn threshold optimization on or off for workloads assigned to this policy.
  • History and window — Set the required data coverage and observation window for threshold analysis.
    • Required history — Minimum amount of historical data ScaleOps must collect before applying a threshold recommendation.
    • History window — Time range used to analyze latency and CPU behavior when calculating the threshold.
  • Target latency — Set a custom latency target for the policy. A stricter (lower) target keeps the threshold closer to the original value; a looser (higher) target allows more aggressive optimization. When not set, ScaleOps uses its default p99 latency target. Available in v1.32.5+
  • Threshold boundaries — Define the maximum adjustment boundaries for threshold optimization relative to the original value.
    • Max boundary (%) — Limits how far the recommended threshold can deviate from the workload’s original CPU threshold.
  • Auto-healing — React to latency and error rate anomalies to ensure threshold optimization remains performance-aware.

Schedule Policies
Available in v1.26.22+

Schedule Policies allow you to automatically switch HPA replica policies by time periods (business hours, nights, weekends, peak periods). This enables you to apply different optimization strategies during specific time windows, optimizing resource usage based on predictable workload patterns.

Overview

Policy Schedule lets you pick a Default Policy and add ordered Override Policies (policy + days + time range). Rules are evaluated top to bottom; the first match wins. Times are specified in UTC. Time ranges may span midnight (e.g., 22:00–06:00).

Creating a Schedule Policy

  1. Navigate to the Policies page under Replicas Optimization
  2. Click Create new policy
  3. Select Policy Schedule
  4. Configure the schedule policy as described below

Schedule Policy Configuration

Default Policy

The default policy is applied to all attached workloads during times that are not covered by any override rules.

Override Rules

Override rules allow you to define specific time periods during which a different policy should be applied. You can add multiple override rules, each specifying:

  • Policy: The policy to apply during this time period
  • Days: Days of the week when this rule applies (e.g., Monday-Friday, Weekends, Every day)
  • Time Range: The time period in UTC (e.g., 10:00–10:59, 22:00–06:00)

Important Notes:

  • Rules are evaluated in order from top to bottom
  • The first matching rule wins
  • Order rules with the most specific rules first
  • Time ranges can span midnight (e.g., 22:00–06:00 means 10 PM to 6 AM)
  • All times are in UTC

Example: Production Schedule Policy with Rush Hour Overrides

Replicas Scheduled policy

Policy Name: production-with-rush-hours

Default Policy: Production

Override Rules:

  • Override Rule 1 – Morning Rush Hour

    • Policy: High Availability
    • Days: Every day
    • Time: 10:00 – 10:59
  • Override Rule 2 – Thursday Batch Window

    • Policy: Lots of Replicas
    • Days: Thursday
    • Time: 11:00 – 14:59

Effective Behavior:

  • Every day, 10:00 – 10:59 → High Availability policy
  • Thursdays, 11:00 – 14:59 → Lots of Replicas policy
  • All other times → Default Production policy

HpaPolicy YAML Reference

Replicas Optimization policies are HpaPolicy custom resources. Create them in the ScaleOps namespace (scaleops-system by default) and attach them with the scaleops.sh/default-replicas-policy annotation. For the rules shared by all policy kinds, see GitOps Policies.

apiVersion: analysis.scaleops.sh/v1alpha1 kind: HpaPolicy metadata: name: my-replicas-policy namespace: scaleops-system spec: policyOptimize: minReplicas: minAllowed: 2 # Min replica boundary considerPdb: true # Never recommend fewer replicas than the PDB needs to stay evictable generalWorkloads: # Static Workloads tab enabled: true window: 168h percentilePercentage: 80 headroomPercentage: 10 predictableWorkloads: # Predictable Workloads tab enabled: true window: 168h percentilePercentage: 80 headroomPercentage: 10 maxReplicas: setMaxReplicas: 50 replicas: prediction: enabled: true lookAheadDuration: 20m thresholdOptimization: enabled: false historyWindow: 168h updatePolicy: requiredWindowCoverageDuration: 24h

Unlike a rightsizing Policy, an HpaPolicy has no per-resource keys (cpu, memory). Each history window belongs to one calculation: static workloads, predictable workloads, prediction or threshold optimization. Write windows in hours or minutes, for example 168h or 20m.

policyOptimize.minReplicas

FieldTypeDescription
minAllowedintegerLowest min replicas ScaleOps may recommend (the Min replica boundary).
setMinReplicasintegerSets a constant min replicas for every workload on the policy, overriding the recommendation.
considerPdbbooleanKeeps the recommendation at or above the replica count the workload’s PodDisruptionBudget needs to stay evictable.
capByOriginMinReplicasbooleanCaps the recommendation at the HPA’s original minReplicas. Default: true.
generalWorkloadsobjectCalculation for static workloads, or for all workloads when predictableWorkloads is disabled.
predictableWorkloadsobjectCalculation for workloads ScaleOps identifies as predictable.

generalWorkloads and predictableWorkloads take the same fields:

FieldTypeDescription
enabledbooleanUse history to set min replicas for this workload class.
windowstring (duration)History window for the min replicas calculation.
percentilePercentageintegerPercentile of historical replica counts used as min replicas.
headroomPercentageintegerExtra replicas added on top of the recommendation, as a percentage.
keepMinReplicasbooleanKeep the HPA’s original minReplicas for this workload class.

policyOptimize.maxReplicas

FieldTypeDescription
setMaxReplicasintegerSets the HPA’s max replicas.

policyOptimize.replicas.prediction

FieldTypeDescription
enabledbooleanScale predictable workloads up ahead of predicted peaks. Default: true.
lookAheadDurationstring (duration)How far ahead to scale before a predicted peak. Default: 20m.
headroomPercentageintegerExtra replicas added to the predicted count, as a percentage.
windowstring (duration)History window used for the prediction.

policyOptimize.thresholdOptimization

Controls Replica Threshold Optimization.

FieldTypeDescription
enabledbooleanOptimize the HPA CPU utilization threshold for workloads on this policy.
historyWindowstring (duration)History window used to analyze latency and CPU behavior.
targetstring (duration)Target latency, for example 250ms. When unset, ScaleOps uses its default p99 latency target.
minUtilizationPercentageintegerLowest CPU utilization threshold ScaleOps may recommend.
maxUtilizationPercentageintegerHighest CPU utilization threshold ScaleOps may recommend.

updatePolicy

FieldTypeDescription
requiredWindowCoverageDurationstring (duration)History ScaleOps must collect before applying recommendations (Required history for optimization).
requiredWindowCoveragePercentageinteger (0–100)Required history as a percentage of the window.

schedulePolicy

A Schedule Policy is an HpaPolicy that switches between other HpaPolicy resources by time. Days are numbered 0 (Sunday) to 6 (Saturday), and times are HH:MM in UTC. Rules are evaluated top to bottom; the first match wins.

apiVersion: analysis.scaleops.sh/v1alpha1 kind: HpaPolicy metadata: name: production-with-rush-hours namespace: scaleops-system spec: schedulePolicy: schedulePolicyConfig: defaultPolicy: production rules: - policyName: high-availability periods: - weeklyConfig: days: [0, 1, 2, 3, 4, 5, 6] beginTime: "10:00" endTime: "10:59" - policyName: lots-of-replicas periods: - weeklyConfig: days: [4] beginTime: "11:00" endTime: "14:59"

schedulePolicy.overrides is deprecated. Use schedulePolicyConfig.

Creating Policies via Helm
Available in v1.35.3+

You can create HPA policies through Helm using the customHpaPolicies field in your values file. Each entry is an HpaPolicy custom resource body. ScaleOps sets apiVersion and kind automatically.

customHpaPolicies: - metadata: name: my-replicas-policy namespace: scaleops-system spec: policyOptimize: minReplicas: minAllowed: 3 maxReplicas: setMaxReplicas: 50