Bitpath

Lesson 2 · Unit 04

Autoscaling

The autoscaler's formula on real numbers, and why requests must be set.

13 exercisesabout 3 min

What you practise

  • The horizontal autoscaler's formula worked on numbers, scaling nodes in outline, why requests must be set

Try a question from this lesson

Pick one

Four Pods each run at 90% of the CPU they asked for. You want them near 60%. If the same work is spread evenly, how many Pods bring the average down to 60%?

Hint

Total up the work first, then divide it by what one Pod should carry.

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

HorizontalPodAutoscaler

A HorizontalPodAutoscaler is a controller that changes replicas for you. At a regular interval it compares a measured value with your target and computes:

desired = ceil(current × measured / target)

It rounds up, stays between minReplicas and maxReplicas, and does nothing when the ratio is within 10% of 1, so small wobbles cause no churn.

The object's apiVersion is autoscaling/v2. Its spec:

YAML
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 60

Concept

Utilization is measured against requests

CPU utilization, for the autoscaler, is not a share of the machine. It is a Pod's real CPU use as a percentage of its CPU request, averaged over the Pods.

A Pod requesting 200m and using 300m is at 150%.

So requests must be set. If a container has no CPU request, utilization cannot be computed, and the autoscaler takes no action on that metric. The scheduler needs the same number to place the Pod.

YAML
resources:
  requests:
    cpu: 200m
  limits:
    cpu: 500m

10 more exercises in the app

  • 3× type the answer
  • 3× multiple choice
  • 2× true or false
  • 1× order the lines
  • 1× match the pairs

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy