Advertisement
Advanced AWS, Amazon EKS (Elastic Kubernetes Service)

How do Horizontal Pod Autoscaler and Cluster Autoscaler work together in EKS to handle scaling?

Short answer

The Horizontal Pod Autoscaler automatically adjusts the number of running pod replicas for a workload based on observed metrics like CPU or custom application metrics, while the Cluster Autoscaler monitors whether there is enough underlying node capacity to actually run those…

Save AWS mock interview
Advertisement
AModel answer
The Horizontal Pod Autoscaler automatically adjusts the number of running pod replicas for a workload based on observed metrics like CPU or custom application metrics, while the Cluster Autoscaler monitors whether there is enough underlying node capacity to actually run those pods and automatically adds or removes EC2 instances from the cluster to match demand, meaning the two work together to scale both the application and the infrastructure beneath it.
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: web-app
spec:
  minReplicas: 2
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70
Real-world example
An online retailer's EKS cluster automatically scales up both the number of application pods and the number of underlying EC2 worker nodes during a flash sale, then scales both back down afterward, all without manual intervention.
Likely follow-ups
  • What is the difference between the Cluster Autoscaler and Karpenter?
  • How do you configure custom metrics for the Horizontal Pod Autoscaler?
Related topics