Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon 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 NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Build a Kubernetes HPA with Safe Scaling Limits and Cooldowns

Use autoscaling/v2 HPA bounds, rate policies and stabilization windows to control workload scaling—while keeping metrics, readiness and node capacity in view.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a Kubernetes HorizontalPodAutoscaler (HPA) to scale a workload within a tested replica range, limit how quickly replicas change, and smooth scale-down decisions. In the stable autoscaling/v2 API, minReplicas and maxReplicas set the bounds; behavior.scaleUp and behavior.scaleDown set rate policies and stabilization windows. Kubernetes does not provide an HPA field literally named “cooldown”: stabilization and rate limits are separate controls. HPA changes workload replicas, while node autoscaling changes cluster capacity.

Choose what the autoscaler should control

An HPA adjusts the desired replica count of a scalable workload based on observed metrics. It is a periodic control loop, not an instantaneous response: Kubernetes documents a default controller sync period of 15 seconds. That interval is not a promise that a new replica will be ready to serve within 15 seconds; scheduling, startup and readiness also affect when added capacity can help. See the Kubernetes HPA concepts documentation.

As an Amazon Associate I earn from qualifying purchases.

Use an HPA when the unit of capacity you need to change is the number of workload Pods. Set its scale target to the workload that should change, and choose a metric that responds predictably when that workload gains or loses replicas. Do not confuse this with node autoscaling: HPA requests workload replicas; a node autoscaler may add or remove cluster infrastructure to accommodate Pods. Those are separate layers of scaling.

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

Set replica limits from service capacity

In an HPA manifest using autoscaling/v2, minReplicas is the lower bound and maxReplicas is the upper bound. The maximum cannot be lower than the minimum. Kubernetes does not prescribe universally safe replica counts: derive the floor and ceiling from tested service capacity, latency objectives, downstream limits and the resource budget. The HorizontalPodAutoscaler API reference documents these fields.

  • Choose the floor: Keep enough replicas for the workload’s baseline availability and response needs. Set a nonzero minimum unless you have deliberately designed and verified scale-to-zero.
  • Choose the ceiling: Cap replicas before the workload can overwhelm dependencies or exceed the cluster’s intended budget. Check whether the cluster can schedule that many Pods with their resource requests.
  • Validate both: Load-test the application and its dependencies at the intended replica range. The HPA can enforce a bound; it cannot determine whether that bound is safe for your system.

Separate rate limits from stabilization

Configure scale-up and scale-down independently in behavior. A rate policy limits how much the replica count may change over a specified periodSeconds. A stabilization window smooths recommendations over time. Rate limits constrain the size of a change; stabilization helps avoid reacting to short-lived metric swings. Neither setting is a substitute for the replica bounds.

Control scale-up

Use behavior.scaleUp.policies to define permitted change rates. A policy can be expressed as a number of Pods or as a percentage change over its periodSeconds. Choose the period and permitted increase based on how quickly the service and its dependencies can safely absorb more traffic. If you configure multiple policies, the default selection allows the largest permitted change. Set selectPolicy: Min when the stricter of the configured limits should apply. selectPolicy: Disabled disables scaling in that direction.

Control scale-down

Kubernetes documents a default downscale stabilization window of 300 seconds (five minutes). During stabilization, the controller uses the highest recent desired-replica recommendation in the window, which helps retain capacity when a metric briefly falls. You can set behavior.scaleDown policies to limit how quickly replicas are removed as well. A longer window retains capacity through longer dips; a shorter one frees resources sooner but can respond to transient lows. The right setting depends on startup time, queueing behavior and service-level objectives—not a universal Kubernetes recommendation.

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

Kubernetes documents no default scale-up stabilization window. Set one only if smoothing short-lived scale-up recommendations is useful for your workload; use rate policies to bound the increase itself. The configurable behavior fields and their semantics are described in the Kubernetes configurable scaling behavior task.

Choose metrics the HPA can use reliably

CPU and memory resource metrics

For resource metrics, the cluster needs the resource metrics API, commonly provided by Metrics Server. CPU utilization is calculated relative to the Pods’ CPU requests. If CPU requests are missing or do not reflect the workload’s capacity needs, the utilization percentage is not a meaningful target for scaling. Resource requests also help the scheduler and node autoscaler reason about placement and capacity.

Other metrics and multiple signals

The HPA can use different metric types, including object and external metrics. When you configure multiple metrics, Kubernetes calculates a desired replica count for each and uses the largest recommendation. This lets a pressure signal ask for more capacity even if another metric is calm. However, if a metric cannot be obtained, the error can prevent a scale-down recommendation; unavailable metrics do not automatically mean it is safe to remove replicas. Check the metric APIs and HPA status when observed behavior differs from expectations. These metric-handling details are covered in the HPA concepts documentation.

Account for readiness and missing measurements

Metrics do not always arrive for every Pod at the same time. Kubernetes treats missing metrics and Pods that are not yet ready conservatively when calculating a scaling recommendation. This can make scaling appear slower or less aggressive than a simple average of the reported measurements would suggest.

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

For CPU-based scaling, startup and readiness timing affect which Pod measurements count. Kubernetes documents a default initial readiness delay of 30 seconds and a default CPU initialization period of five minutes. Ensure readiness means the Pod can actually serve, rather than merely that its process has started. If a workload has a longer initialization phase, review the HPA concepts documentation’s guidance on startup and CPU initialization before interpreting early CPU readings.

Inspect the HPA’s status and conditions to diagnose scaling that does not match expectations. Confirm that the target workload, metric source and resource requests are correct, and that the relevant metrics API is available. When several metrics are configured, account for both the largest-recommendation rule and the possibility that a metric error blocks scale-down.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep workload and node capacity in one plan

An HPA can raise the desired replica count even when the cluster has no room to schedule the new Pods. Node autoscaling may add infrastructure in response, but it does not change the HPA’s replica bounds or scaling behavior. Conversely, an HPA’s replica ceiling does not guarantee that the corresponding Pods fit on the available nodes.

Plan the two layers together: use realistic Pod resource requests, confirm the cluster can accommodate the intended peak, and decide what should happen when that capacity is unavailable. Kubernetes’ node autoscaling documentation explains how node autoscaling adjusts cluster capacity and why Pod resource requests matter to those decisions.

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

Use scale-to-zero only with an activation signal

Resource metrics such as CPU and memory require running Pods to provide measurements, so they cannot by themselves wake a workload from zero. Kubernetes v1.37 documentation says HPA scale-to-zero is beta and applies to object or external metrics, not resource metrics. For that release, setting minReplicas: 0 requires at least one object or external metric and the HPAScaleToZero feature gate enabled in both kube-apiserver and kube-controller-manager. Verify the cluster version and feature-gate state rather than assuming these requirements apply identically to older versions. Details appear in the Kubernetes v1.37 scale-to-zero announcement.

Before setting a zero minimum, verify that the external or object signal remains available while the workload has no Pods, that it can trigger activation, and that the application’s startup delay is acceptable. Otherwise, retain a nonzero minimum.

A practical configuration sequence

  1. Identify the scalable target. Choose the workload resource whose scale subresource should be controlled, and check its Pod resource requests and readiness behavior.
  2. Select and verify a metric. Confirm the metric API is installed and available. For CPU utilization, make sure CPU requests are meaningful; for other metric types, verify their signal remains useful across the replica range.
  3. Set tested replica bounds. Choose minReplicas and maxReplicas from service tests, dependency capacity and budget. Do not copy generic example counts as a production limit.
  4. Set the change rates. Define scale-up and scale-down policies using Pods or Percent and an appropriate periodSeconds. If multiple policies are present, decide whether the default largest allowed change or selectPolicy: Min better protects the system.
  5. Choose stabilization windows. Start from the documented five-minute downscale default unless measured workload behavior justifies a different trade-off. Decide separately whether scale-up stabilization is needed.
  6. Apply and observe. Apply the HPA manifest, then inspect HPA status, conditions, observed metrics and workload readiness while exercising representative load and recovery scenarios. Confirm both that the intended replica limits are respected and that nodes can schedule the Pods.
  7. Revisit after changes. Re-test when resource requests, startup behavior, dependencies, metrics or service objectives change; each can alter what a safe scaling policy means.

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.

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
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

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.