IEEE Access (Jan 2024)

Implement HPA for Nginx Service Using Custom Metrics Under Kubernetes Framework

  • Hanlin Zhou,
  • Chan Huah Yong

DOI
https://doi.org/10.1109/ACCESS.2024.3509876
Journal volume & issue
Vol. 12
pp. 189722 – 189734

Abstract

Read online

Kubernetes, as a container orchestration and management tool suitable for large-scale and complex scenarios, is essentially the recommended management tool for containers like Docker. Kubernetes includes a Horizontal Pod Autoscaler (HPA) component that can automatically scale the number of containers based on resource metrics. However, by default, it only supports CPU and memory metrics. In real-world business scenarios, such as web services, CPU and memory usage may not accurately reflect service quality. HTTP status codes can better represent service status; for example, a 5xx status code indicates an abnormal request result, which more accurately reflects the actual service situation compared to CPU metrics. To address these challenges, this paper proposes an HPA architecture based on HTTP status codes as custom metrics to improve system service availability. The paper designs two types of custom status code HPA: HHPA, implemented using Prometheus, and HHPA-2, implemented using Python code. The results show that under high-load conditions, HHPA and HHPA-2, which use 5xx status code custom metrics, improved response speed by 30%, reduced abnormal requests by over 50%, and provided more than 99% high availability compared to HPA using CPU metrics, This study contributes by demonstrating the advantages of using HTTP status codes as custom metrics in the HPA for more effective resource scaling. It provides models and data references aimed at improving HPA service performance and enhancing system service availability. Furthermore, the development of new components using Python code offers valuable insights for Kubernetes research.

Keywords