Autoscale Using Prometheus Metrics

Custom autoscaling with Prometheus metrics

The hdx-scaler, or autoscaler, provides Kubernetes cluster scaling using Prometheus metrics.

Use precision to set the scale ratio

The precision configuration sets the number of digits to round to when calculating the average-to-target ratio. The default is 10. A higher precision number smooths the transitions when scaling up and down. Use this setting to set when the ratio rounds to zero to trigger the desired number of pods to reach zero. For more frequent scaling to zero, set a lower precision. Set a higher precision value to keep small ratios above zero and have less frequent scaling to zero.

  • A ratio of 0.045 with precision ≤1 rounds to zero, scaling down to zero pods.
  • A ratio of 0.045 with precision ≥2 rounds up and keeps one replica active.

In this example, merge_duty_cycle, part of merge-controller, is the metric that determines when merge-peer scales up, if it's been set to a low or zero precision value.

merge-peer:
    cpu: 4
    memory: 4Gi
    hdxscalers:
    - metric: merge_duty_cycle
      port: 27182
      target_value: 0.5
      cool_down_seconds: 40
      app: merge-controller
      precision: 1
    replicas: 1-5
    scale_profile: I
    service: merge-peer

Use metrics from other services to autoscale from minimum replicas

The autoscaler uses external metrics to decide when to scale up a scaled-to-zero service. If no separate app metric is specified, the scaler sets the minimum replica to 1 instead of 0.