# Copyright 2018 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ConfigMap
metadata:
  name: config-autoscaler
  namespace: knative-serving
data:
  # Static parameters:

  # The Revision ContainerConcurrency field specifies the maximum number
  # of requests the Container can handle at once. Container concurrency
  # target percentage is how much of that maximum to use in a stable
  # state. E.g. if a Revision specifies ContainerConcurrency of 10, then
  # the Autoscaler will try to maintain 7 concurrent connections per pod
  # on average. A value of 0.7 is chosen because the Autoscaler panics
  # when concurrency exceeds 2x the desired set point. So we will panic
  # before we reach the limit.
  # TODO(#1956): tune target usage based on empirical data.
  # TODO(#2016): Revert to 0.7 once incorrect reporting is solved
  container-concurrency-target-percentage: "1.0"

  # The container concurrency target default is what the Autoscaler will
  # try to maintain when the Revision specifies unlimited concurrency. A
  # value of 100 is chosen because it's enough to allow vertical pod
  # autoscaling to tune resource requests. E.g. maintaining 1 concurrent
  # "hello world" request doesn't consume enough resources to allow VPA
  # to achieve efficient resource usage (VPA CPU minimum is 300m).
  container-concurrency-target-default: "100"

  # When operating in a stable mode, the autoscaler operates on the
  # average concurrency over the stable window.
  stable-window: "60s"

  # When observed average concurrency during the panic window reaches 2x
  # the target concurrency, the autoscaler enters panic mode. When
  # operating in panic mode, the autoscaler operates on the average
  # concurrency over the panic window.
  panic-window: "6s"

  # Max scale up rate limits the rate at which the autoscaler will
  # increase pod count. It is the maximum ratio of desired pods versus
  # observed pods.
  max-scale-up-rate: "10"

  # Concurrency quantum of time is the minimum time is the quantum in
  # which concurrency will be measured by the queue-proxy.
  # The maximum concurrency in each of the "buckets" (of the duration
  # defined here) is taken and the average over all buckets is
  # reported.
  concurrency-quantum-of-time: "100ms"

  # Scale to zero feature flag
  enable-scale-to-zero: "true"

  # This does nothing for now.
  enable-vertical-pod-autoscaling: "false"

  # Tick interval is the time between autoscaling calculations.
  tick-interval: "2s"

  # Dynamic parameters (take effect when config map is updated):

  # Scale to zero threshold is the total time between traffic dropping to
  # zero and when its resources are deprovisioned.  Must be at least 30s
  # more than scale-to-zero-grace-period (min: 60s)
  scale-to-zero-threshold: "5m"

  # Scale to zero grace period is the time an inactive revision is left
  # running before it is scaled to zero (min: 30s).
  scale-to-zero-grace-period: "2m"
