[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Autoscaling\n\nKf leverages the Kubernetes Horizontal Pod Autoscaler (HPA)\nto automatically scale the number of Pods in a App. When autoscaling is enabled\nfor an App, an HPA object is created and bound to the App object. It then dynamically\ncalculates the target scale and sets it for the App.\n\nHow Kf scaling works\n--------------------\n\nThe number of Pods that are deployed for a Kf App is\ncontrolled by its underlying Deployment object's `replica` field. The target\nnumber of Deployment replicas is set through the App's `replicas` field.\n\nScaling can be done manually with the [`kf scale`](/migrate/kf/docs/2.1/cli/kf-scale)\ncommand. This command is disabled when autoscaling is enabled to avoid conflicting targets.\n\nHow the Kubernetes Horizontal Pod Autoscaler works\n--------------------------------------------------\n\nThe Horizontal Pod Autoscaler (HPA) is implemented as a Kubernetes API resource\n(the HPA object) and a control loop (the HPA controller) which periodically\ncalculates the number of desired replicas based on current resource utilization.\nThe HPA controller then passes the number to the target object that implements the\nScale subresource. The actual scaling is delegated to the underlying object and\nits controller. You can find more information in the [Kubernetes documentation](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/).\n\n### How the Autoscaler determines when to scale\n\nPeriodically, the HPA controller queries the resource utilization against\nthe metrics specified in each HorizontalPodAutoscaler definition. The controller\nobtains the metrics from the resource metrics API for each Pod. Then the\ncontroller calculates the utilization value as a percentage of the equivalent\nresource request. The desired number of replicas is then calculated based on the\nratio of current percentage and desired percentage. You can read more about the\n[autoscaling algorithm](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#algorithm-details) in the Kubernetes documentation.\n\n### Metrics\n\nKf uses HPA v1 which only supports CPU as the target\nmetric.\n\nHow the Kubernetes Horizontal Autoscaler works with Kf\n------------------------------------------------------\n\nWhen autoscaling is enabled for a Kf App, the Kf\ncontroller will create an HPA object based on the scaling limits and rules\nspecified on the App. Then the HPA controller fetches the specs from the HPA\nobject and scales the App accordingly.\n\nThe HPA object will be deleted if Autoscaling is disabled or if the\ncorresponding App is deleted."]]