Documentation ¶
Overview ¶
Package autoscaler calculates the number of pods necessary for the desired level of concurrency per pod (stableConcurrencyPerPod). It operates in two modes, stable mode and panic mode.
Stable mode calculates the average concurrency observed over the last 60 seconds and adjusts the observed pod count to achieve the target value. Current observed pod count is the number of unique pod names which show up in the last 60 seconds.
Panic mode calculates the average concurrency observed over the last 6 seconds and adjusts the observed pod count to achieve the stable target value. Panic mode is engaged when the observed 6 second average concurrency reaches 2x the target stable concurrency. Panic mode will last at least 60 seconds--longer if the 2x threshold is repeatedly breached. During panic mode the number of pods is never decreased in order to prevent flapping.
Index ¶
Constants ¶
const (
ConfigName = "config-autoscaler"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Autoscaler ¶
type Autoscaler struct { *Config // contains filtered or unexported fields }
Autoscaler stores current state of an instance of an autoscaler
func New ¶
func New(config *Config, model v1alpha1.RevisionRequestConcurrencyModelType, reporter StatsReporter) *Autoscaler
New creates a new instance of autoscaler
type Config ¶
type Config struct { // Feature flags. EnableScaleToZero bool EnableVPA bool // Target concurrency knobs for different concurrency modes. SingleTargetConcurrency float64 MultiTargetConcurrency float64 VPAMultiTargetConcurrency float64 // General autoscaler algorithm configuration. MaxScaleUpRate float64 StableWindow time.Duration PanicWindow time.Duration ScaleToZeroThreshold time.Duration ConcurrencyQuantumOfTime time.Duration }
Config defines the tunable autoscaler parameters
func NewConfigFromConfigMap ¶
NewConfigFromConfigMap creates a Config from the supplied ConfigMap
func NewConfigFromMap ¶
NewConfigFromMap creates a Config from the supplied map
func (*Config) TargetConcurrency ¶
func (c *Config) TargetConcurrency(model v1alpha1.RevisionRequestConcurrencyModelType) float64
type Measurement ¶
type Measurement int
Measurement represents the type of the autoscaler metric to be reported
const ( // DesiredPodCountM is used for the pod count that autoscaler wants DesiredPodCountM Measurement = iota // RequestedPodCountM is used for the requested pod count from kubernetes RequestedPodCountM // ActualPodCountM is used for the actual number of pods we have ActualPodCountM // ObservedPodCountM is used for the observed number of pods we have ObservedPodCountM // ObservedStableConcurrencyM is the average of requests count in each 60 second stable window ObservedStableConcurrencyM // ObservedPanicConcurrencyM is the average of requests count in each 6 second panic window ObservedPanicConcurrencyM // TargetConcurrencyM is the desired number of concurrent requests for each pod TargetConcurrencyM // PanicM is used as a flag to indicate if autoscaler is in panic mode or not PanicM )
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
Reporter holds cached metric objects to report autoscaler metrics
func NewStatsReporter ¶
NewStatsReporter creates a reporter that collects and reports autoscaler metrics
type Stat ¶
type Stat struct { // The time the data point was collected on the pod. Time *time.Time // The unique identity of this pod. Used to count how many pods // are contributing to the metrics. PodName string // Average number of requests currently being handled by this pod. AverageConcurrentRequests float64 // Number of requests received since last Stat (approximately QPS). RequestCount int32 }
Stat defines a single measurement at a point in time
type StatMessage ¶
StatMessage wraps a Stat with identifying information so it can be routed to the correct receiver.
type StatsReporter ¶
type StatsReporter interface {
Report(m Measurement, v float64) error
}
StatsReporter defines the interface for sending autoscaler metrics