{"canonical_url":"https://engineer.company/glossary/horizontal-pod-autoscaling/","content_markdown":"# Horizontal pod autoscaling\n\n## What it is\n\nHorizontal Pod autoscaling adjusts how many replicas a Kubernetes workload runs.\nIts controller checks a measured signal and changes the target's desired replica\ncount within configured bounds. A workload that receives more traffic may get\nadditional Pods. As demand falls, the controller can return capacity to the\ncluster. Scaling changes the number of running instances, while the resources\nrequested by each instance are set elsewhere.\n\nAn autoscaler needs a metric, a target and a suitable workload. A common setup\nuses average CPU utilisation relative to the requested CPU for the Pods. Other\nsetups use a custom application metric or an external measurement, such as\ndemand waiting in a queue. The controller checks the signal periodically. When\nthe measured value is above its target, it can calculate a larger desired\npopulation. Tolerance, missing measurements, readiness and scaling behaviour\nsettings influence what change is actually made.\n\nChoose the signal with the work in mind. CPU use can be a useful measure for\ncompute-bound processing. A worker spending most of its time waiting for an\nupstream service can have low CPU use while its queue grows. For that service, a\nmeasure of waiting work or age may better reflect what users experience. A\nsignal should tell the controller something useful about what an additional\nreplica can accomplish.\n\n## Why it matters\n\nTraffic can arrive faster than a team can adjust replicas manually. An overnight\nimport can add a backlog to a worker service. A public event can produce several\ntimes the normal request rate for a short period. Scaling can help while those\nrequests are arriving, and an appropriately sized baseline can still handle the\nwork present before replacements become ready.\n\nThe time required to add capacity matters. A new Pod needs scheduling, startup\nand readiness. The cluster may need more node capacity, which has its own delay.\nA metric might report a rapidly growing queue while the expected new workers\nremain pending. An autoscaler can react to the signal and still leave customers\nwaiting if the deployment takes too long to add usable capacity. Establish which\ndelay dominates a burst and measure the entire path.\n\nScaling down is another control problem. Removing workers as soon as one sample\nlooks quiet can cause repeated churn and force the application to rebuild caches\nor reconnect to a service. A stabilisation policy can preserve capacity while\nshort dips pass. A longer delay can cost more if it leaves many replicas idle.\nThe suitable behaviour comes from observed work patterns and the cost of losing\ncapacity while another burst arrives.\n\n## What it looks like in practice\n\nImagine a worker service that converts incoming documents. Measure how long the\noldest queued request has waited and how many jobs workers can complete per\nminute. Select a target that fits the product's waiting-time goal. Set enough\nminimum capacity to absorb the normal arrival pattern during startup. Use a load\ntest with a gradual increase and a sudden spike. Record arrival rate, queue\ndepth, desired replicas, running replicas and usable workers.\n\nA simple observed example helps establish whether the policy is doing what its\nowner expects. With three replicas, an average CPU utilisation of 75 percent and\na 50 percent target, the basic scaling ratio suggests five replicas after\nrounding up. Configured bounds and behaviour policies can limit that change. Log\nthe input and the next desired population, then follow how many workers actually\nbecome ready. This example applies when the metric samples describe the expected\npods and the controller has enough information to use them.\n\nA second test can saturate an upstream dependency that all workers share. Extra\nPods help only when they can do more useful work. If every worker waits on the\nsame fixed connection limit, scaling can amplify contention. Try a bounded\nworker concurrency limit and observe whether added workers increase completion\nrate. Use peak results and cost to decide where more replicas help and where the\nshared service needs attention.\n\nEngineer's\n[multi-cloud container operations case study](/portfolio/ran-20-docker-apps-on-google-cloud-and-aws/)\ndocuments deploying and monitoring applications across clouds and using\nKubernetes to diagnose orchestration issues. That monitoring discipline is\nuseful when developing a scaling policy. The illustrative worker test follows\nboth the controller's desired count and the throughput it actually delivers. It\ngives operators a way to tell whether a deployment, the cluster's capacity or\nthe application itself is limiting recovery.\n\n## Where it goes wrong\n\nAn autoscaler may have too little information when some Pods have no usable\nmetric samples. Check its conditions and the health of the metrics source. When\nusing resource utilisation, give the relevant containers appropriate requests. A\nCPU percentage is interpreted in relation to a request and may be unavailable\nwhen that relationship is missing. Review whether each contributing Pod has a\nuseful signal during startup as well as during steady traffic.\n\nIt is easy to choose a target without considering the consequences of repeated\nrescheduling. Inspect what happens to in-flight work when replicas are removed,\nespecially if a job can be retried. Give the worker time to drain or return its\ntask to a queue. Add an explicit floor for the times when a service has to\naccept bursts promptly and a ceiling that limits demand on shared resources.\n\nFinally, test operation when the controller cannot get the desired number of\nready replicas. Verify that the backlog and pending workload remain observable\nand that overload follows an intentional policy. Revisit the metric and bounds\nwhen the product's workloads change. A successful scaling setup explains what\ncauses the desired count to change and shows the resulting effect on a real\nrequest or job completion time.\n\n## Further reading\n\n- [Kubernetes Horizontal Pod Autoscaling](https://kubernetes.io/docs/concepts/workloads/autoscaling/horizontal-pod-autoscale/).\n  Explains metrics, the control loop and scaling behaviour.\n- [Kubernetes autoscaling walkthrough](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/).\n  Shows a scale-up and scale-down exercise.\n- [The HorizontalPodAutoscaler v2 API](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/horizontal-pod-autoscaler-v2/).\n  Describes metrics, conditions and behaviour settings.\n\n\u003chttps://engineer.company/glossary/horizontal-pod-autoscaling/\u003e\n","date_modified":"2026-11-25T07:18:46Z","description":"Follow the Kubernetes replica control loop and account for metric delays, startup time and bursty work.","formats":{"gemtext":"https://engineer.company/glossary/horizontal-pod-autoscaling/index.gmi","gopher":"https://engineer.company/glossary/horizontal-pod-autoscaling/gophermap","html":"https://engineer.company/glossary/horizontal-pod-autoscaling/","json":"https://engineer.company/glossary/horizontal-pod-autoscaling/index.json","markdown":"https://engineer.company/glossary/horizontal-pod-autoscaling/index.md","pdf":"https://engineer.company/glossary/horizontal-pod-autoscaling/index.pdf"},"kind":"page","language":"en","title":"What is horizontal pod autoscaling?","url":"https://engineer.company/glossary/horizontal-pod-autoscaling/","version":1}