Tuning autoscaling sensitivity using the API

To customize the autoscaling sensitivity and requisites, set the target and metric fields in the spec.autoscaling.tuning parameter.

The metric field is the data you are watching to make autoscaling decisions, which you can set to either AUTOSCALING_METRIC_CONCURRENCY or AUTOSCALING_METRIC_RPS (requests per second):

  • Concurrency is the number of requests that each replica of the model shall aim to handle at once.
  • RPS is the calculated requests per second handled over the polling period.
  • Target is the target value of the metric that you aim to maintain. If the Target value is exceeded when calculating the metric value, new replicas will be spun up or down to maintain the Target value as the upper bound.

    The autoscaler targets a percentage of this value, defined by targetUtilization (70 by default), to preserve capacity for traffic bursts. If target is not specified, the default value is 100 for concurrency and 200 for requests per second (RPS).

Set these values as follows. Autoscaling tuning applies only to deployments in Knative deployment mode:
# cat ./examples/mlflow/model-spec-cml-registry.json
{
  "namespace": "serving-default",
  "name": "mlflow-wine-test-from-registry-onnx",
  "spec": {
    "source": {
      "registrySource": {
        "modelId": "yf0o-hrxq-l0xj-8tk9",
        "version": 1
      }
    },
    "autoscaling": {
      "minReplicas": 0,
      "maxReplicas": 4,
      "tuning": {
        "metric": "AUTOSCALING_METRIC_CONCURRENCY",
        "target": 25
      }
    }
  }
}

The example scales the deployment between zero and four replicas while targeting a maximum of 25 concurrent requests per replica. The autoscaler adjusts the number of replicas to maintain this target. By default, scaling occurs at 70% of the target value, allowing additional capacity for traffic spikes before the limit is reached.