Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does HPA(Horizontal pod autoscaling) considers the mean of CPU utilization of multiple containers(in a pod) to scale the pods?

Tags:

I would like to know, if HPA considers the mean of CPU utilization of multiple containers in a pod, in order to scale up/down the no. of pods. For instance, if I specify a HPA like below for a deployment(pod) that has 2 containers. In order for the HPA to scale up, does it require the CPU utilization to be reached to 80% in both the containers? In other words, If container A has CPU utilization of 80% but container B has CPU utilization of only 60%. Does that mean that the pods will not be scaled up by HPA. As far as I have observed, this is the case. But I am not sure about this, since there is no explicit statement regarding this in the kubernetes documentation. And unfortunately, I am not the best of developers to figure this out from the source code. Any help & if possible with reference, would be greatly appreciated. Thank you so much.

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: blackbox-rc-hpa
  namespace: monitoring
spec:
  scaleTargetRef:
    apiVersion: v1
    kind: extensions/v1beta1
    name: blackbox
  minReplicas: 1
  maxReplicas: 4
  targetCPUUtilizationPercentage: 80
like image 242
Suhas Chikkanna Avatar asked Sep 09 '17 22:09

Suhas Chikkanna


People also ask

What does the Kubernetes horizontal pod Autoscaler do?

The Horizontal Pod Autoscaler changes the shape of your Kubernetes workload by automatically increasing or decreasing the number of Pods in response to the workload's CPU or memory consumption, or in response to custom metrics reported from within Kubernetes or external metrics from sources outside of your cluster.

What is HPA autoscaling?

HPA is a form of autoscaling that increases or decreases the number of pods in a replication controller, deployment, replica set, or stateful set based on CPU utilization—the scaling is horizontal because it affects the number of instances rather than the resources allocated to a single container.

How does Kubernetes autoscaling work?

In Kubernetes, a HorizontalPodAutoscaler automatically updates a workload resource (such as a Deployment or StatefulSet), with the aim of automatically scaling the workload to match demand. Horizontal scaling means that the response to increased load is to deploy more Pods.

How is HPA calculated?

HPA calculates pod utilization as total usage of all containers in the pod divided by total request. It looks at all containers individually and returns if container doesn't have request.


1 Answers

The controller calculates the utilization value as a percentage on the containers in each pod and then takes the mean. So in your scenerio mean will be 70% https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/

like image 134
Innocent Anigbo Avatar answered Sep 30 '22 15:09

Innocent Anigbo