algorithm

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

README

Autoscaling Algorithms

This package provides various scaling algorithms for Pod Autoscaling, including implementations for

  • APA (Adaptive Pod Autoscaler),
  • KPA (KNative Pod Autoscaler),
  • HPA (Horizontal Pod Autoscaler), and more.

These algorithms are designed to dynamically compute the desired number of replicas based on current pod usage and scaling specifications, optimizing resource usage and ensuring high availability and performance for workloads.

ScalingAlgorithm Interface is a common interface for all scaling algorithms, requiring the implementation of the ComputeTargetReplicas method, which calculates the number of replicas based on current metrics and scaling specifications.

type ScalingAlgorithm interface {
    ComputeTargetReplicas(currentPodCount float64, context ScalingContext) int32
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApaScalingAlgorithm

type ApaScalingAlgorithm struct{}

func (*ApaScalingAlgorithm) ComputeTargetReplicas

func (a *ApaScalingAlgorithm) ComputeTargetReplicas(currentPodCount float64, context common.ScalingContext) int32

ComputeTargetReplicas - Apa's algorithm references and enhances the algorithm in the following paper: Huo, Qizheng, et al. "High Concurrency Response Strategy based on Kubernetes Horizontal Pod Autoscaler." Journal of Physics: Conference Series. Vol. 2451. No. 1. IOP Publishing, 2023.

type HpaScalingAlgorithm

type HpaScalingAlgorithm struct{}

HpaScalingAlgorithm can be used by any scaler without customized algorithms

func (*HpaScalingAlgorithm) ComputeTargetReplicas

func (a *HpaScalingAlgorithm) ComputeTargetReplicas(currentPodCount float64, context common.ScalingContext) int32

type KpaScalingAlgorithm

type KpaScalingAlgorithm struct{}

func (*KpaScalingAlgorithm) ComputeTargetReplicas

func (a *KpaScalingAlgorithm) ComputeTargetReplicas(currentPodCount float64, context common.ScalingContext) int32

type ScalingAlgorithm

type ScalingAlgorithm interface {
	// ComputeTargetReplicas calculates the number of replicas needed based on current metrics
	// and the provided scaling specifications.
	//
	// Parameters:
	// currentPodCount - the current number of ready pods
	// context - an interface that provides access to scaling parameters like target values and tolerances
	//
	// Returns:
	// int32 - the calculated target number of replicas
	ComputeTargetReplicas(currentPodCount float64, context common.ScalingContext) int32
}

Jump to

Keyboard shortcuts

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