A company runs a web application on Google Kubernetes Engine (GKE) that experiences sudden traffic spikes. The operations team notices that the application's response time increases significantly during these spikes despite having Horizontal Pod Autoscaler (HPA) configured. They want to ensure consistent performance. What should they do?
Configuring the HPA to consume custom metrics from the Kubernetes Custom Metrics API (e.g., using the Stackdriver adapter or Prometheus adapter) allows it to scale based on request latency metrics such as p95 or p99 duration. This directly measures user-facing performance so the HPA adds pods when latency rises, not just when CPU is saturated. This approach responds to application-level bottlenecks, which is the correct fix for latency-driven scaling on Google Kubernetes Engine.
Why this answer
Configuring the HPA to use custom metrics based on request latency allows the autoscaler to react directly to the application's performance degradation. Unlike CPU-based metrics, which may not reflect actual user-facing latency during traffic spikes, custom metrics like request latency provide a more accurate signal for scaling decisions, ensuring consistent response times.
Exam trap
Google Cloud often tests the misconception that CPU-based HPA is sufficient for all scaling scenarios, but the trap here is that CPU metrics do not capture application-level performance degradation caused by request latency or queue buildup during traffic spikes.
How to eliminate wrong answers
Option A is wrong because increasing the CPU request limit does not improve scaling responsiveness; it only changes the threshold at which the HPA triggers, potentially delaying scaling and not addressing the root cause of latency spikes. Option C is wrong because creating multiple node pools with different machine types addresses node-level resource diversity but does not solve the pod-level scaling issue; the HPA still needs appropriate metrics to scale pods effectively. Option D is wrong because manually scaling the deployment during expected spikes is not a scalable or automated solution; it contradicts the purpose of using HPA and increases operational overhead, especially for unpredictable traffic patterns.