liveBook · Manning

HorizontalPodAutoscaler

As explained in Acing the Frontend Interview

The Horizontal Pod Autoscaler is a Kubernetes controller that adjusts a workload's number of pods according to resource or custom metrics.

HorizontalPodAutoscaler (HPA) automatically adjusts a Kubernetes workload’s pod count as demand changes. It scales up when average CPU usage exceeds a target and scales down while preserving configured minimum capacity. section 6.3

A practical HPA setup includes:

  • Define CPU and memory resource requests and limits on the Deployment so Kubernetes can measure pod usage. section 6.3
  • Set minimum and maximum replicas, such as 3 and 20, to constrain elasticity and preserve baseline availability. section 6.3
  • Use resource metrics or expose custom metrics such as requests per second through the Metrics Server and Prometheus Adapter. section 6.3
  • Pair workload scaling with Cluster Autoscaler when existing nodes cannot accommodate newly created pods. section 6.3

Scaling a high-traffic API

Run kubectl autoscale deployment api-deployment --cpu-percent=70 --min=3 --max=20 to scale an API between three and twenty pods around 70% average CPU utilization. For multi-metric policies, use an autoscaling/v2 manifest targeting a Deployment and combining CPU utilization with average HTTP requests per second. section 6.3

How Acing the Frontend Interview covers it

How deep it goes
Explains configuration, thresholds, metrics, and cluster coordination through a command and declarative manifest.
Examples
Uses a high-traffic API, kubectl autoscale command, and autoscaling/v2 multi-metric manifest.
What it assumes
Assumes Kubernetes workloads and resource metrics while requiring resource requests and limits for measurement.
What you can do after
Operate/configure it with replica bounds, CPU targets, and custom request-rate metrics.
How it connects
Connects horizontal scaling with resource metrics, custom metrics, load balancing, and Cluster Autoscaler.

Also explained in

Compare how 4 books explain HorizontalPodAutoscaler →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Frontend Interview. The section links point to the parts of the book it draws on.