Kubernetes HPA change polling interval
I use Horizontal Pod Autoscaler with External
metric based on a value provided by DataDog agent
apiVersion: datadoghq.com/v1alpha1
kind: DatadogMetric
metadata:
name: queue-size
spec:
query: "max:redis.key.length{key:my-tasks}.fill(zero)"
Corresponding HPA configuration
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: celery-worker
metrics:
- type: External
external:
metric:
name: "datadogmetric@default:queue-size"
I want workers to be scaled almost immediately as queue grows, so need polling period to be at most 2-5
seconds. By default it's 30 seconds (as per docs)
How do I change poll interval on k8s side? Is there a flag when configuring HPA or should I tune DataDog agent instead?
Solution 1:
Kubernetes implements horizontal pod autoscaling as a control loop that runs intermittently (it is not a continuous process). The interval is set by the --horizontal-pod-autoscaler-sync-period parameter to the kube-controller-manager (and the default interval is 15 seconds). You should tweak the value as per your requirement