Load Testing
Load Testing
Load tests are an important part of software development, as they help ensure that your application can handle the expected traffic. Several tools are available to run load tests, including Apache JMeter, Gatling and Locust.
Kubernetes - HPA - Increase the load
TO DO
Run a load test on your Spring Boot application. Record a video of the load test, showing: - The load test running; - The HPA (Horizontal Pod Autoscaler) running.
Tips
- In the HPA link, you will find an example of a load test. It targets an Apache httpd, but you can adapt it to your Spring Boot project;
- An example address for the load test is:
http://<dns-name>/info, since thegatewayhas an/infoendpoint that returns information about the application. You can use this endpoint to load test your application.
Example of HPA
Open three terminal windows, one for each tab below.
Create the HPA (Horizontal Pod Autoscaler) for the gateway deployment. The HPA will automatically scale the number of pods in the deployment based on CPU usage.
Check the status of the HPA:
kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
gateway Deployment/gateway cpu: 1%/50% 1 10 1 66s
Watch the HPA status:
At the end of the test, delete the HPA:
Open another terminal window and monitor the pods in the gateway deployment:
Open another terminal window and run the load test against the gateway deployment. This will simulate a high load on the application, causing the HPA to scale the number of pods in the deployment.
kubectl run -i --tty load-generator --rm --image=busybox:1.28 --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://gateway/health-check; done"
In the command above, the wget command is used to send requests to the /info endpoint of the gateway deployment. The while loop will continue to send requests until you stop it (e.g., by pressing Ctrl+C). The interval between requests is set to 0.01 seconds, which simulates a high load on the application. Try to increase and decrease the interval to see how the HPA reacts to different loads.