Skip to content

EKS HPA - Testing Horizontal Pod Autoscaler

0

Hi,
Before deploying an HPA, I wanted to really feel comfortable with how it works, by scaling a deployment up and down, and observing results.

Existing tutorials run wget in a loop to generate load. Which is better than nothing. But what about a proper load tester that can be scaled in a controlled and understandable way? I searched for such software and found k6. "k6 Open Source is designed for load testing".

Also our company's deployment was Django, rather than PHP. It seemed interesting to build a new Django app from scratch, very basic, and embed a stress command into it. Then hit that with k6. Play around to adjust the settings.

Maybe this would be interesting to other people also.

All the code is https://github.com/sdarwin/django-load-test

If you have any feedback, let me know.

asked a year ago363 views

1 Answer
0
Accepted Answer

Thank you for sharing your approach to testing Horizontal Pod Autoscaler (HPA) in EKS. Your method of using k6 as a load testing tool is indeed more sophisticated than the simple wget loop approach commonly found in tutorials.

The Horizontal Pod Autoscaler is a powerful Kubernetes feature that automatically adjusts the number of pod replicas based on observed metrics (typically CPU utilization, but it can use other metrics as well). It's designed to help applications handle fluctuating traffic without manual intervention.

Your approach of creating a basic Django app with a built-in stress command that can be targeted with k6 is a great way to test HPA functionality in a controlled environment. This provides several advantages over the simple wget loop:

  1. More realistic load patterns: k6 can generate various types of load patterns that better simulate real-world traffic
  2. Better metrics and reporting: k6 provides detailed performance metrics
  3. Controlled scaling: You can gradually increase load to observe exactly when HPA triggers
  4. More representative of real applications: Testing with Django is closer to actual production workloads than a simple PHP server

When testing HPA, it's important to observe:

  • How quickly it scales up when load increases
  • Whether it correctly scales to the appropriate number of replicas based on your target CPU utilization
  • How it behaves when load decreases (noting that scale-down typically has a 5-minute default delay)
  • How the scaling affects your application's performance

Your GitHub repository with a complete example will certainly be valuable to others looking to understand HPA behavior in a more controlled and realistic testing environment.

One thing to keep in mind is that HPA can work with different metrics sources beyond just CPU, including custom metrics and external metrics, which could be interesting to explore in future iterations of your testing approach.
Sources
Scale pod deployments with Horizontal Pod Autoscaler - Amazon EKS
Workload scaling - AWS Prescriptive Guidance
Running highly-available applications - Amazon EKS

answered a year ago

AWS
EXPERT

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.