October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Debug Kubernetes HPA Thrashing and Repeated Scaling

Debug repeated Kubernetes HPA scaling by tracing replica ownership, metric inputs, startup effects, and stabilization and rate-limit settings.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If your Kubernetes workload keeps scaling up and then back down, trace each replica decision to its metric before changing the target. Check who controls the replica count, whether the metric is accurate and available, and how HPA timing and scaling policies handle short-lived changes. The concrete settings below apply to Kubernetes HorizontalPodAutoscaler (HPA); defaults and available fields vary by Kubernetes version and cluster configuration.

Start by confirming who is changing replicas

Kubernetes documentation calls frequent replica fluctuation “thrashing” or “flapping.” Begin with the HPA and its target workload:

As an Amazon Associate I earn from qualifying purchases.

  1. Run kubectl get hpa to list HPAs and their current and desired replica counts.
  2. Run kubectl describe hpa <hpa-name> to inspect the target, reported metrics, conditions, and scaling events.
  3. Inspect the target workload and its scale subresource. Check whether GitOps, an operator, a deployment tool, or a person is also writing its replica count.

If the HPA’s desired count and the workload’s replica count disagree, do not assume the metric target is the problem. Establish which component owns the field and whether another writer is overriding HPA decisions. The official inspection commands are documented in the Kubernetes HPA guide; detecting competing writers depends on the tools and configuration in your cluster.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Trace each recommendation back to its metric

For every metric listed by the HPA, record its target, observed value, units, labels or selector, and observation time. Verify that the metric represents the workload you intend to scale, and that the value is not stale or aggregated across unrelated Pods.

#1 Best Overall

HPA derives a replica recommendation from the observed-metric-to-target ratio. When an HPA uses multiple metrics, it calculates a recommendation for each and chooses the largest desired replica count. A metric fetch failure can also prevent a scale-down recommendation from being applied when another available metric recommends scaling down. Inspect metrics one at a time rather than treating the HPA’s displayed result as a single opaque signal. These behaviors are described in the HorizontalPodAutoscaler API reference and HPA guide.

Verify the metrics pipeline

For CPU and memory metrics, confirm that the resource Metrics API is serving current data and that metrics-server is collecting and aggregating kubelet readings. Kubernetes describes this as a basic pipeline for node and Pod CPU and memory—not a general source for every possible HPA metric. See the resource metrics pipeline guide.

Custom and external metrics need their corresponding API and pipeline. Check the exact metric requested by the HPA, its adapter mapping, scope, and response. If readings disappear intermittently or the HPA reports metric errors, resolve availability or mapping problems before tuning the target or adding smoothing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check startup, readiness, and resource requests

Startup CPU bursts, changing readiness, and misleading CPU requests can distort the utilization HPA sees. Kubernetes documents two controller-manager defaults for CPU metric handling: --horizontal-pod-autoscaler-cpu-initialization-period is 5 minutes, and --horizontal-pod-autoscaler-initial-readiness-delay is 30 seconds. These are cluster-wide controller settings, not per-HPA knobs; managed clusters may control how they are configured. Confirm the actual values for your cluster in the HPA documentation.

Compare the timing of startup CPU use and readiness changes with the HPA’s reported samples. Review CPU requests and whether startup and readiness probes reflect when the application can handle traffic—not merely when its process has started. A probe that marks a Pod ready while it is still doing heavy initialization can make capacity appear available too early.

Compare signal timing with HPA behavior

Put metric scrape and aggregation intervals, HPA reconciliation, Pod startup time, and the length of demand bursts on one timeline. If a metric crosses its target briefly and then reverses, the HPA may receive alternating recommendations. The important question is whether the oscillation comes from real workload changes, noisy observations, or a mismatch between reaction time and application startup.

Kubernetes documents these relevant defaults in its current HPA references. They are version- and configuration-dependent, so check your cluster’s Kubernetes version, HPA API version, controller-manager settings, and managed-service behavior before relying on them.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Control Documented default What it affects
Scale-down stabilization window 300 seconds Buffers short drops in recommendations before reducing replicas.
Scale-up stabilization window 0 seconds Allows scale-up recommendations to proceed without a default stabilization delay, subject to scaling policies.
Metric tolerance 10% Defines a band around the target in which small variations do not change the desired count; cluster-wide or per-HPA configuration may override it.
CPU initialization period 5 minutes Controller setting for handling CPU samples during startup.
Initial readiness delay 30 seconds Controller setting for handling readiness during startup.

These values are documented in the HPA API reference and HPA guide. They are configuration defaults, not performance guarantees. The API reference also describes a default scale-up policy that permits at most doubling replicas or adding four Pods over a 15-second period; verify the policy and configuration in your release rather than assuming that example is active.

Use stabilization and directional policies deliberately

Buffer short dips with scale-down stabilization

spec.behavior.scaleDown.stabilizationWindowSeconds lets HPA consider recent recommendations before applying a downscale. The documented default is 300 seconds; during that window, the algorithm chooses the highest recommendation, which can prevent a transient load dip from immediately removing capacity. Increasing the window may help when short-lived low readings cause needless scale-downs. It cannot correct a bad metric, a broken metrics pipeline, or a competing replica writer.

Set rate limits independently for each direction

Directional scaling policies cap how much replicas can change over a period. They can limit scale-down churn, permit faster increases, or disable scaling in one direction. The API also supports choosing the policy that allows the maximum or minimum change. Apply a scale-down limit when rapid decreases are the problem; do not slow scale-up indiscriminately if the service needs to respond quickly to rising demand.

Use tolerance for small variations near the target

Tolerance creates a no-action band around the target. The API reference documents a default cluster-wide tolerance of 10% and describes per-direction tolerance support where available. Check the Kubernetes version and feature availability before relying on a per-HPA field. Tolerance may help when a valid, correctly scoped metric hovers near its target; it is not a substitute for fixing incorrect units, aggregation, or metric availability.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Match the symptom to a test

Observed pattern What to check
Metric repeatedly crosses the target Verify units, selector, and aggregation. If the signal is valid but fluctuates narrowly around target, evaluate tolerance or a longer scale-down stabilization window.
Scale-up follows startup CPU, then scale-down follows readiness Review startup and readiness probes, CPU requests, and CPU initialization handling.
HPA status disagrees with workload replicas Compare HPA status and conditions with the target’s scale subresource; identify other writers to the replica field.
Several metrics point to different replica counts Inspect each metric and its availability; HPA uses the highest successful desired count.
Metrics intermittently disappear Check the relevant resource, custom, or external metrics API and adapter mappings before changing targets.

Change one control and watch service health

Once the input and cause are understood, make one relevant change at a time. For transient low-load dips, test a longer scale-down stabilization window or a lower scale-down rate. Restrict scale-up only if the workload can tolerate a slower response. Excessive smoothing can leave the replica graph calmer while latency rises or capacity falls short.

During each change, compare replicas with queue depth, latency, saturation, and error rate. A useful configuration must handle real increases promptly, avoid reacting to transient noise, remove capacity at an acceptable pace, and retain a usable metric while replicas are starting or absent. There is no universally best setting; the trade-off depends on the workload’s response time and service objectives.

Check version-specific scale-to-zero behavior

If scaling to zero is involved, verify the cluster version and metric type. In Kubernetes v1.37, HPA scale-to-zero is Beta and enabled by default for object and external metrics, not CPU or memory metrics alone. A workload scaled to zero also needs a way to observe demand and handle cold starts; a durable queue or buffering layer may be important. This behavior is release-specific, as described in the HPA guide.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.