The Kubernetes Horizontal Pod Autoscaler (HPA) relies on resource metrics such as CPU or memory utilization to make scaling decisions. However, these metrics are lagging indicators that reflect work already in progress rather than pending demand. This approach fails for I/O-bound workloads where CPU usage does not correlate with throughput, and it cannot scale deployments to zero during idle periods.
This thesis presents a comparative experimental study of HPA and KEDA (Kubernetes-based Event-driven Autoscaler), which uses event-source metrics as leading indicators. We designed three experiments using a RabbitMQ message queue and Go microservices deployed on a local Kubernetes cluster: a CPU-bound workload baseline, an I/O-bound workload test, and a scale-to-zero evaluation.
Results demonstrate that KEDA outperforms HPA across all scenarios. In the CPU-bound baseline, KEDA drained the queue in 65 seconds compared to HPA's 175 seconds, and HPA reached maximum replicas only after the queue was already empty. In the I/O-bound experiment, HPA failed entirely, maintaining only one replica throughout because CPU utilization remained near zero despite a 1000-message backlog. KEDA, observing queue depth directly, scaled immediately and cleared the backlog in 60 seconds versus HPA's 8 minutes. KEDA also scaled to zero replicas during idle periods, a capability HPA does not have.
These findings indicate that KEDA provides superior autoscaling for event-driven and I/O-bound workloads, while HPA remains appropriate for simpler CPU-bound scenarios.
|