Horizontal Pod Autoscaling (HPA) is a Kubernetes resource that automatically scales the number of pod replicas in a workload horizontally—adding or removing pods—to match observed demand. It operates by continuously monitoring specified metrics, such as average CPU utilization, memory consumption, or custom metrics exposed by the application. When the measured values cross a defined threshold, the HPA controller instructs the Kubernetes API to adjust the replica count within configured minimum and maximum bounds, ensuring efficient resource use and application responsiveness.
Glossary
Horizontal Pod Autoscaling (HPA)

What is Horizontal Pod Autoscaling (HPA)?
Horizontal Pod Autoscaling (HPA) is a core Kubernetes controller that automatically adjusts the number of pod replicas in a deployment or stateful set based on observed resource utilization or custom application metrics.
In edge AI deployments, HPA is crucial for managing inference workloads on edge clusters where demand can be sporadic. It enables cost-efficient scaling of model-serving pods, like those running an inference server, in response to fluctuating inference requests or batch processing jobs. For stateful edge services, HPA is often paired with a StatefulSet to manage scaling while preserving pod identity and storage. Effective use requires defining meaningful metrics, setting appropriate thresholds, and understanding pod startup latency to prevent thrashing in dynamic edge environments.
Key Features of HPA
Horizontal Pod Autoscaling (HPA) is a core Kubernetes controller that dynamically adjusts the number of pod replicas in a deployment or replica set based on observed resource utilization or custom application metrics.
Resource-Based Scaling
The most common scaling trigger is based on CPU and memory utilization. HPA calculates the current utilization as a percentage of the requested resources defined in the pod's resource requests. For example, if a pod requests 500m CPU and is using 250m, utilization is 50%. The HPA controller uses this to determine if the average across all pods exceeds or falls below the target threshold, triggering a scale-out or scale-in event.
Custom & External Metrics
Beyond CPU and memory, HPA can scale based on custom metrics (application-specific, e.g., requests per second, queue length) and external metrics (from systems outside the cluster, e.g., cloud pub/sub queue depth). This requires a metrics server for core resources and an adapter for the Kubernetes Metrics API, such as the Prometheus Adapter, to expose custom metrics. This allows scaling on business logic, like the number of pending tasks in a job queue.
Scaling Algorithm & Cooldown
HPA calculates the desired replica count using the formula: desiredReplicas = ceil[currentReplicas * (currentMetricValue / desiredMetricValue)]. To prevent rapid, flapping scale changes, HPA employs cooldown delays:
- scaleUp and scaleDown stabilization windows (configurable, defaults vary).
- The --horizontal-pod-autoscaler-downscale-stabilization flag (default 5 minutes) prevents scaling down too aggressively after a recent scale-up.
Configurable Scaling Behavior
The behavior field in the HPA spec (API version autoscaling/v2) allows fine-grained control over scaling speed and direction. Policies can be set independently for scaleUp and scaleDown:
- policies: Define the percentage or number of pods that can be added/removed per period.
- selectPolicy: Can be
Min,Max, orDisabledto control which policy is used. - stabilizationWindowSeconds: Prevents flapping by considering historical metric values.
Integration with Cluster Autoscaler
HPA works in tandem with the Cluster Autoscaler. While HPA adjusts the number of pods, the Cluster Autoscaler adjusts the number of nodes in the cluster. If HPA scales out pods and there are insufficient node resources, the Cluster Autoscaler will provision a new node to accommodate the pending pods. Conversely, it can remove underutilized nodes after HPA scales in pods. This creates a fully elastic infrastructure layer.
Use in Edge AI Orchestration
In Edge AI deployments, HPA manages the scale of inference server pods hosting ML models. It can scale based on:
- Custom metrics like inference request latency or batch queue size.
- External metrics from edge device fleets. This ensures edge clusters handle sporadic inference loads efficiently, scaling model replicas across available edge nodes to meet low-latency service-level objectives while conserving resources during low-activity periods.
HPA vs. VPA (Vertical Pod Autoscaling)
A technical comparison of the two primary Kubernetes autoscaling controllers, focusing on their scaling dimension, operational mechanics, and suitability for edge AI workloads.
| Feature | Horizontal Pod Autoscaling (HPA) | Vertical Pod Autoscaling (VPA) |
|---|---|---|
Primary Scaling Dimension | Number of Pod replicas | Resource requests/limits (CPU, memory) of individual Pods |
Core Mechanism | Adjusts the | Modifies the |
Typical Trigger Metrics | CPU utilization, memory usage, or custom/external metrics (e.g., inference requests per second). | Historic and current CPU/memory usage of containers, with recommendations for resource values. |
Workload Disruption During Update | Minimal to none for stateless workloads; new Pods are created before old ones are terminated (rolling update). | Requires Pod restart/recreation to apply new resource limits, causing temporary downtime for the affected Pod. |
Stateful Workload Support | Supported via StatefulSet, but scaling down requires careful manual orchestration for data safety. | Not recommended; restarting Pods in a StatefulSet can disrupt stateful services and storage attachments. |
Edge AI Deployment Suitability | High. Ideal for scaling stateless inference services across a cluster to handle request load. Aligns with immutable infrastructure principles. | Low to Moderate. Useful for right-sizing resource-constrained edge Pods, but the required Pod restart is often unacceptable for always-on, low-latency inference services. |
Resource Fragmentation Risk | None. Scales by adding/removing whole Pods. | High. Increasing resource requests for one Pod can prevent other Pods from being scheduled on the same node, leading to inefficient bin packing. |
Primary Use Case | Handling variable traffic/request load for stateless services (e.g., model inference APIs). | Correcting initial under-provisioning of CPU/memory for long-running, stable-load services where occasional restarts are acceptable. |
HPA in Practice: Platforms & Integrations
Horizontal Pod Autoscaling (HPA) is a core Kubernetes primitive, but its power is amplified when integrated with the broader cloud-native ecosystem. This section details the key platforms, tools, and complementary technologies that define modern HPA implementations.
Kubernetes Metrics Server
The Kubernetes Metrics Server is the foundational component for HPA. It is a cluster-wide aggregator of resource usage data, collecting metrics like CPU and memory utilization from each node's Kubelet. HPA queries the Metrics Server API to obtain the current resource consumption of pods. Without it, HPA cannot function for standard resource metrics. It is typically deployed as a single pod in the kube-system namespace and is a prerequisite for any basic HPA configuration.
Prometheus Adapter for Custom Metrics
To scale on custom metrics (e.g., requests per second, queue length), HPA requires an external metrics pipeline. The Prometheus Adapter is the standard solution. It acts as a bridge between HPA and a Prometheus monitoring stack.
- It translates Prometheus queries into the custom metrics API that HPA understands.
- Allows scaling based on virtually any metric stored in Prometheus.
- Configuration involves writing PromQL queries that the adapter will execute at a regular interval to feed metrics to the HPA controller.
Vertical Pod Autoscaling (VPA)
Vertical Pod Autoscaling (VPA) is a complementary technology to HPA. While HPA adjusts the number of pod replicas, VPA automatically adjusts the resource requests and limits (CPU, memory) of individual pods.
- Use Case: Corrects misconfigured resource requests. A pod under-provisioned at startup can be given more resources without a restart (with the
UpdateMode: Initial). - Caution: VPA in
UpdateMode: Autotypically requires pod recreation, which can be disruptive. It is often used in conjunction with HPA for memory-bound applications, where HPA handles request load and VPA manages per-pod memory allocation.
Cluster Autoscaler (CA)
The Cluster Autoscaler works in tandem with HPA at the infrastructure layer. When HPA scales out a deployment and there are insufficient cluster resources to schedule the new pods, the pods enter a Pending state.
- The Cluster Autoscaler detects these unschedulable pods.
- It automatically provisions new worker nodes (in cloud environments) to accommodate the workload.
- Conversely, it scales down nodes that are underutilized, consolidating pods to reduce costs.
- This creates a full-stack, elastic scaling solution: HPA scales pods, CA scales the underlying nodes.
Integration with Service Meshes (Istio)
Service meshes like Istio provide rich application-layer traffic metrics (e.g., requests per second, request duration, error rates) that are ideal for autoscaling. The integration flow is:
- Istio's telemetry system (Mixer/Telemetry V2) collects metrics from the service proxy (Envoy).
- These metrics are exposed to Prometheus.
- The Prometheus Adapter is configured with rules to make these metrics available to the Kubernetes custom metrics API.
- HPA is configured to scale based on metrics like
istio_requests_per_second. This enables scaling directly on business-relevant traffic patterns rather than just infrastructure utilization.
Frequently Asked Questions
Horizontal Pod Autoscaling (HPA) is a core Kubernetes feature for dynamically scaling workloads. These questions address its operation, configuration, and role in edge AI deployments.
Horizontal Pod Autoscaling (HPA) is a Kubernetes controller that automatically adjusts the number of pod replicas in a deployment, replica set, or stateful set based on observed utilization of specified metrics. It works by periodically querying the Kubernetes Metrics API (or a custom metrics API) to check the current metric values (e.g., average CPU utilization) against the target values defined in the HPA resource. If the metric exceeds the target, the HPA instructs the workload controller to scale out (add pods). If it falls below, the HPA scales in (remove pods). This creates a feedback loop that maintains application performance under variable load.
For example, an HPA configured for a model inference service might target 70% average CPU utilization. If traffic spikes cause CPU usage to hit 85%, the HPA will increase the replica count to distribute the load, bringing the average back toward the target.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Horizontal Pod Autoscaling (HPA) is a core component of the Kubernetes control plane for managing application scale. These related concepts define the ecosystem in which HPA operates, particularly for edge AI deployments.
Pod
A Pod is the smallest and simplest deployable unit in Kubernetes. It represents a single instance of a running process in a cluster and can contain one or more application containers that share:
- Storage volumes
- A unique network IP
- Configuration for how to run the containers
For edge AI, a Pod typically packages a model inference server, its dependencies, and any sidecar containers for logging or monitoring. HPA scales the number of identical Pod replicas in a Deployment or StatefulSet.
Vertical Pod Autoscaling (VPA)
Vertical Pod Autoscaling (VPA) is a Kubernetes component that automatically adjusts the CPU and memory resource requests and limits for Pods based on historical usage. Unlike HPA, which changes the number of Pods, VPA changes the size of individual Pods.
Key differences from HPA:
- Scaling Dimension: Modifies pod resource allocation (vertical) vs. pod count (horizontal).
- Use Case: Optimizes resource utilization for applications with unpredictable but stable growth, rather than handling bursty traffic.
- Edge Consideration: On resource-constrained edge nodes, VPA can help right-size models to fit within available memory, but may require pod restarts.
Cluster Autoscaler
The Cluster Autoscaler is a Kubernetes component that automatically adjusts the size of the node pool in a cluster. It adds nodes when Pods fail to schedule due to insufficient resources and removes nodes that are underutilized.
Interaction with HPA:
- HPA creates new Pod replicas to handle load.
- If there is no capacity on existing nodes for the new Pods, they become "pending."
- The Cluster Autoscaler detects pending Pods and provisions a new node.
- The Pods then schedule onto the new node.
For edge deployments, this is often less relevant as edge node fleets are typically static, but it's critical in cloud-based management clusters.
Custom Metrics API
The Custom Metrics API (part of the Kubernetes Metrics Server ecosystem) allows HPA to scale based on application-specific metrics beyond standard CPU and memory. This is essential for scaling AI/ML workloads where load is better measured by:
- Inference requests per second (RPS)
- Queue length of a processing pipeline
- GPU utilization percentage
- Application-level business metrics (e.g., predictions served)
To use it, a metrics adapter (like Prometheus Adapter) must be installed to serve custom metrics from a monitoring system to the Kubernetes API.
Kubernetes Operator
A Kubernetes Operator is a method of packaging, deploying, and managing a Kubernetes application using custom resources and controllers. Operators encode human operational knowledge (like backup procedures or complex scaling logic) into software.
Relation to HPA: For stateful edge AI applications (e.g., a distributed model training job or a database-backed inference service), a custom Operator might manage scaling logic more sophisticated than HPA's simple metrics, coordinating with StatefulSets and persistent volumes. The Operator can use the HPA API or implement its own control loop.
Desired State
Desired State is a core Kubernetes paradigm where a user declares the intended configuration of the system (e.g., "run 5 replicas of this Pod"). Controllers like the HPA continuously observe the actual state and make changes to drive the system toward the desired state.
HPA's Role:
- User defines a desired metric target (e.g., 70% CPU utilization).
- HPA's control loop constantly checks the actual metric value.
- If actual > desired, HPA updates the Deployment's desired replica count upward.
- The Deployment controller then works to create more Pods to match this new desired state.
This reconciliation loop is fundamental to all automated orchestration in Kubernetes.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us