scaling

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const MinActivators = 2

The minimum number of activators a revision will get.

Variables

This section is empty.

Functions

This section is empty.

Types

type Autoscaler

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

Autoscaler stores current state of an instance of an autoscaler.

func New

func New(
	namespace string,
	revision string,
	metricClient metrics.MetricClient,
	lister corev1listers.EndpointsLister,
	deciderSpec *DeciderSpec,
	reporterCtx context.Context) (*Autoscaler, error)

New creates a new instance of autoscaler

func (*Autoscaler) Scale

func (a *Autoscaler) Scale(ctx context.Context, now time.Time) (desiredPodCount, excessBC, numAct int32, validScale bool)

Scale calculates the desired scale based on current statistics given the current time. desiredPodCount is the calculated pod count the autoscaler would like to set. validScale signifies whether the desiredPodCount should be applied or not.

func (*Autoscaler) Update

func (a *Autoscaler) Update(deciderSpec *DeciderSpec) error

Update reconfigures the UniScaler according to the DeciderSpec.

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 {
	// TickInterval denotes how often we evaluate the scale suggestion.
	TickInterval     time.Duration
	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 value of panic to stable concurrency
	// ratio to transition into panic mode.
	PanicThreshold float64
	// StableWindow is needed to determine when to exit panic mode.
	StableWindow time.Duration
	// The name of the k8s service for pod information.
	ServiceName string
}

DeciderSpec is the parameters in which the Revision should 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

	// NumActivators is the computed number of activators
	// necessary to back the revision.
	NumActivators 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(ctx context.Context, decider *Decider) (*Decider, error)

Create instantiates the desired Decider.

func (*MultiScaler) Delete

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

Delete stops and removes a Decider.

func (*MultiScaler) Get

func (m *MultiScaler) Get(ctx 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(ctx context.Context, decider *Decider) (*Decider, error)

Update applied 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 UniScaler

type UniScaler interface {
	// Scale either proposes a number of replicas, available excess burst capacity,
	// and suggested number of activators, or skips proposing.
	// The proposal is requested at the given time.
	// The returned boolean is true if and only if a proposal was returned.
	Scale(context.Context, time.Time) (int32, int32, int32, bool)

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

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

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