Kubernetes Autoscaling
Horizontal Pod Autoscaler
Horizontal Pod Autoscaler
โ History of Scaling
| Class | Lead Time | Level of Automation |
| ------------------- | ----------------------- | ------------------- |
| Self-hosted Servers | Weeks to Months | Low |
| Virtualisation | Days to Weeks | Low |
| VPS | Hours to Days | Moderate |
| Instances | Minutes to Hours | Moderate to High |
| Pods | Seconds to Minutes | High |
| Functions | Milliseconds to Seconds | High |
| #nocode | Speed of thought ** | Infinite โ |
** ( อกยฐ อส อกยฐ)
3๐คท Reasons for Scaling
Scale Up
Scale Down
| Level | Monitoring | Scaling | Benchmarking |
| ---------------- | ---------------- | ------------------------- | --------------------------- |
| 0 - Static | No observability | Best guess provisioning | No performance/load testing |
| 1 - Coarse | CPU/Memory | Based on CPU/Memory | Manual load tests |
| 2 - Qualitative | Calls/Latency | Based on calls/latency | Automatic but periodic |
| 3 - Optimising | Tracing | Adaptive | Automatic per commit |
5
๐จโ๐งโ๐ฆ Autoscaling Maturity Model
๐จโ๐งโ๐ฆ Autoscaling Maturity Model
๐จโ๐งโ๐ฆ Autoscaling Maturity Model
๐จโ๐งโ๐ฆ Autoscaling Maturity Model
๐ Scaling in Kubernetes
desiredReplicas = ceil(currentReplicas * (currentMetric/desiredMetric))
Given a target utilization of 60%
And a replica count of 4 pods
And an average utilization of 80%
When the HPA evaluates the metrics
Then it should scale to 6 pods.
ceil(4 * (100/60)).
11
๐ Scaling in Kubernetes
kubectl scale --replicas=2 -n instana-dev deployment/fizzbuzz
๐ Scaling in Kubernetes
apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: fizzbuzz namespace: instana-dev spec: minReplicas: 3 maxReplicas: 10 metrics: - resource: name: cpu target: averageUtilization: 60 type: Utilization type: Resource scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: fizzbuzz
๐ Scaling in Kubernetes