Scale SpringBoot App based on Thread Pool State
Make sure metrics are scraped. You're going to watch for a
threadpool_size
metric. Refer your k8s/prometheus distro docs to get prometheus service discovery working for you.Write a horizontal pod autoscaler (HPA) based on a Prometheus metric:
- Setup Prometheus-Adapter and follow the HPA walkthrough.
- Or follow this guide https://github.com/stefanprodan/k8s-prom-hpa
Depending on what k8s distro you are using, you might have different ways to get the Prometheus and prometheus discovery:
- (example platform built-in) https://cloud.google.com/stackdriver/docs/solutions/gke/prometheus
- (example product) https://docs.datadoghq.com/integrations/prometheus/
- (example opensource) https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack
- any other prometheus solution