scaling

package
v0.26.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2021 License: Apache-2.0 Imports: 20 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decider

type Decider struct {
	metav1.ObjectMeta
	Spec   DeciderSpec
	Status DeciderStatus
}

Decider is a resource which observes the request load of a Revision and recommends a number of replicas to run. +k8s:deepcopy-gen=true

func (*Decider) DeepCopy

func (in *Decider) DeepCopy() *Decider

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Decider.

func (*Decider) DeepCopyInto

func (in *Decider) DeepCopyInto(out *Decider)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type DeciderSpec

type DeciderSpec struct {
	MaxScaleUpRate   float64
	MaxScaleDownRate float64
	// The metric used for scaling, i.e. concurrency, rps.
	ScalingMetric string
	// The value of scaling metric per pod that we target to maintain.
	// TargetValue <= TotalValue.
	TargetValue float64
	// The total value of scaling metric that a pod can maintain.
	TotalValue float64
	// The burst capacity that user wants to maintain without queuing at the POD level.
	// Note, that queueing still might happen due to the non-ideal load balancing.
	TargetBurstCapacity float64
	// ActivatorCapacity is the single activator capacity, for subsetting.
	ActivatorCapacity float64
	// PanicThreshold is the threshold at which panic mode is entered. It represents
	// a factor of the currently observed load over the panic window over the ready
	// pods. I.e. if this is 2, panic mode will be entered if the observed metric
	// is twice as high as the current population can handle.
	PanicThreshold float64
	// StableWindow is needed to determine when to exit panic mode.
	StableWindow time.Duration
	// ScaleDownDelay is the time that must pass at reduced concurrency before a
	// scale-down decision is applied.
	ScaleDownDelay time.Duration
	// InitialScale is the calculated initial scale of the revision, taking both
	// revision initial scale and cluster initial scale into account. Revision initial
	// scale overrides cluster initial scale.
	InitialScale int32
	// Reachable describes whether the revision is referenced by any route.
	Reachable bool
}

DeciderSpec is the parameters by which the Revision should be scaled.

type DeciderStatus

type DeciderStatus struct {
	// DesiredScale is the target number of instances that autoscaler
	// this revision needs.
	DesiredScale int32

	// ExcessBurstCapacity is the difference between spare capacity
	// (how much more load the pods in the revision deployment can take before being
	// overloaded) and the configured target burst capacity.
	// If this number is negative: Activator will be threaded in
	// the request path by the PodAutoscaler controller.
	ExcessBurstCapacity int32
}

DeciderStatus is the current scale recommendation.

type MultiScaler

type MultiScaler struct {
	// contains filtered or unexported fields
}

MultiScaler maintains a collection of UniScalers.

func NewMultiScaler

func NewMultiScaler(
	stopCh <-chan struct{},
	uniScalerFactory UniScalerFactory,
	logger *zap.SugaredLogger) *MultiScaler

NewMultiScaler constructs a MultiScaler.

func (*MultiScaler) Create

func (m *MultiScaler) Create(_ context.Context, decider *Decider) (*Decider, error)

Create instantiates the desired Decider.

func (*MultiScaler) Delete

func (m *MultiScaler) Delete(_ context.Context, namespace, name string)

Delete stops and removes a Decider.

func (*MultiScaler) Get

func (m *MultiScaler) Get(_ context.Context, namespace, name string) (*Decider, error)

Get returns the copy of the current Decider.

func (*MultiScaler) Inform

func (m *MultiScaler) Inform(event types.NamespacedName) bool

Inform sends an update to the registered watcher function, if it is set.

func (*MultiScaler) Poke

func (m *MultiScaler) Poke(key types.NamespacedName, stat metrics.Stat)

Poke checks if the autoscaler needs to be run immediately.

func (*MultiScaler) Update

func (m *MultiScaler) Update(_ context.Context, decider *Decider) (*Decider, error)

Update applies the desired DeciderSpec to a currently running Decider.

func (*MultiScaler) Watch

func (m *MultiScaler) Watch(fn func(types.NamespacedName))

Watch registers a singleton function to call when DeciderStatus is updated.

type ScaleResult added in v0.15.0

type ScaleResult struct {
	// DesiredPodCount is the number of pods Autoscaler suggests for the revision.
	DesiredPodCount int32
	// ExcessBurstCapacity is computed headroom of the revision taking into
	// the account target burst capacity.
	ExcessBurstCapacity int32
	// ScaleValid specifies whether this scale result is valid, i.e. whether
	// Autoscaler had all the necessary information to compute a suggestion.
	ScaleValid bool
}

ScaleResult holds the scale result of the UniScaler evaluation cycle.

type UniScaler

type UniScaler interface {
	// Scale computes a scaling suggestion for a revision.
	Scale(*zap.SugaredLogger, time.Time) ScaleResult

	// Update reconfigures the UniScaler according to the DeciderSpec.
	Update(*DeciderSpec)
}

UniScaler records statistics for a particular Decider and proposes the scale for the Decider's target based on those statistics.

func New

func New(
	reporterCtx context.Context,
	namespace, revision string,
	metricClient metrics.MetricClient,
	podCounter resources.EndpointsCounter,
	deciderSpec *DeciderSpec) UniScaler

New creates a new instance of default autoscaler implementation.

type UniScalerFactory

type UniScalerFactory func(*Decider) (UniScaler, error)

UniScalerFactory creates a UniScaler for a given PA using the given dynamic configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL