Skip to content

Horizontal pod autoscaling

replica scaling based on a metric target

What it is

Horizontal Pod autoscaling adjusts how many replicas a Kubernetes workload runs. Its controller checks a measured signal and changes the target’s desired replica count within configured bounds. A workload that receives more traffic may get additional Pods. As demand falls, the controller can return capacity to the cluster. Scaling changes the number of running instances, while the resources requested by each instance are set elsewhere.

An autoscaler needs a metric, a target and a suitable workload. A common setup uses average CPU utilisation relative to the requested CPU for the Pods. Other setups use a custom application metric or an external measurement, such as demand waiting in a queue. The controller checks the signal periodically. When the measured value is above its target, it can calculate a larger desired population. Tolerance, missing measurements, readiness and scaling behaviour settings influence what change is actually made.

Choose the signal with the work in mind. CPU use can be a useful measure for compute-bound processing. A worker spending most of its time waiting for an upstream service can have low CPU use while its queue grows. For that service, a measure of waiting work or age may better reflect what users experience. A signal should tell the controller something useful about what an additional replica can accomplish.

  • View up between cargo container stacks towards the sky
    Photo: distelAPPArath / Pixabay
  • Cargo cranes spanning a container terminal
    Photo: wasi1370 / Pixabay

Use the concept in a decision

Put “What is horizontal pod autoscaling?” to work in a real decision. We can help relate the concept to the system you are building or buying. Packaged to behave identically on a laptop, on a test server and in production, and to scale up when a busy week arrives.

Explore our services Get in touch

Test the assumptions behind the term

Use the explanation and linked work to frame questions for your project. We can examine the assumptions with you before a tool is chosen. Ran 20 Docker apps on Google Cloud and AWS — 20 containerised applications deployed and watched

Ran 20 Docker apps on Google Cloud and AWS Get in touch

Why it matters

Traffic can arrive faster than a team can adjust replicas manually. An overnight import can add a backlog to a worker service. A public event can produce several times the normal request rate for a short period. Scaling can help while those requests are arriving, and an appropriately sized baseline can still handle the work present before replacements become ready.

The time required to add capacity matters. A new Pod needs scheduling, startup and readiness. The cluster may need more node capacity, which has its own delay. A metric might report a rapidly growing queue while the expected new workers remain pending. An autoscaler can react to the signal and still leave customers waiting if the deployment takes too long to add usable capacity. Establish which delay dominates a burst and measure the entire path.

Scaling down is another control problem. Removing workers as soon as one sample looks quiet can cause repeated churn and force the application to rebuild caches or reconnect to a service. A stabilisation policy can preserve capacity while short dips pass. A longer delay can cost more if it leaves many replicas idle. The suitable behaviour comes from observed work patterns and the cost of losing capacity while another burst arrives.

What it looks like in practice

Imagine a worker service that converts incoming documents. Measure how long the oldest queued request has waited and how many jobs workers can complete per minute. Select a target that fits the product’s waiting-time goal. Set enough minimum capacity to absorb the normal arrival pattern during startup. Use a load test with a gradual increase and a sudden spike. Record arrival rate, queue depth, desired replicas, running replicas and usable workers.

A simple observed example helps establish whether the policy is doing what its owner expects. With three replicas, an average CPU utilisation of 75 percent and a 50 percent target, the basic scaling ratio suggests five replicas after rounding up. Configured bounds and behaviour policies can limit that change. Log the input and the next desired population, then follow how many workers actually become ready. This example applies when the metric samples describe the expected pods and the controller has enough information to use them.

A second test can saturate an upstream dependency that all workers share. Extra Pods help only when they can do more useful work. If every worker waits on the same fixed connection limit, scaling can amplify contention. Try a bounded worker concurrency limit and observe whether added workers increase completion rate. Use peak results and cost to decide where more replicas help and where the shared service needs attention.

Engineer’s multi-cloud container operations case study documents deploying and monitoring applications across clouds and using Kubernetes to diagnose orchestration issues. That monitoring discipline is useful when developing a scaling policy. The illustrative worker test follows both the controller’s desired count and the throughput it actually delivers. It gives operators a way to tell whether a deployment, the cluster’s capacity or the application itself is limiting recovery.

Where it goes wrong

An autoscaler may have too little information when some Pods have no usable metric samples. Check its conditions and the health of the metrics source. When using resource utilisation, give the relevant containers appropriate requests. A CPU percentage is interpreted in relation to a request and may be unavailable when that relationship is missing. Review whether each contributing Pod has a useful signal during startup as well as during steady traffic.

It is easy to choose a target without considering the consequences of repeated rescheduling. Inspect what happens to in-flight work when replicas are removed, especially if a job can be retried. Give the worker time to drain or return its task to a queue. Add an explicit floor for the times when a service has to accept bursts promptly and a ceiling that limits demand on shared resources.

Finally, test operation when the controller cannot get the desired number of ready replicas. Verify that the backlog and pending workload remain observable and that overload follows an intentional policy. Revisit the metric and bounds when the product’s workloads change. A successful scaling setup explains what causes the desired count to change and shows the resulting effect on a real request or job completion time.

Further reading

Glossary

Choose for your actual constraints

Bring the deployment path, the operational risks and the people on call. We can scope a change with checks, a recovery route and clear ownership.

See what it costs Get in touch

Make the terminology practical

Ask how “What is horizontal pod autoscaling?” applies to your organisation. A concrete example from your current system is enough to start the discussion.

Explore our services
welcome@engineer.company +45 50 10 61 84 Copenhagen, Denmark
QR code for Horizontal pod autoscaling
Take this page with youhttps://engineer.company/glossary/horizontal-pod-autoscaling/