Add HighestRandomWeight Loadbalancing Algorithm
This commit is contained in:
parent
9b42b5b930
commit
02443545e7
10 changed files with 936 additions and 112 deletions
|
|
@ -53,10 +53,11 @@ type Model struct {
|
|||
|
||||
// Service holds a service configuration (can only be of one type at the same time).
|
||||
type Service struct {
|
||||
LoadBalancer *ServersLoadBalancer `json:"loadBalancer,omitempty" toml:"loadBalancer,omitempty" yaml:"loadBalancer,omitempty" export:"true"`
|
||||
Weighted *WeightedRoundRobin `json:"weighted,omitempty" toml:"weighted,omitempty" yaml:"weighted,omitempty" label:"-" export:"true"`
|
||||
Mirroring *Mirroring `json:"mirroring,omitempty" toml:"mirroring,omitempty" yaml:"mirroring,omitempty" label:"-" export:"true"`
|
||||
Failover *Failover `json:"failover,omitempty" toml:"failover,omitempty" yaml:"failover,omitempty" label:"-" export:"true"`
|
||||
LoadBalancer *ServersLoadBalancer `json:"loadBalancer,omitempty" toml:"loadBalancer,omitempty" yaml:"loadBalancer,omitempty" export:"true"`
|
||||
HighestRandomWeight *HighestRandomWeight `json:"highestRandomWeight,omitempty" toml:"highestRandomWeight,omitempty" yaml:"highestRandomWeight,omitempty" label:"-" export:"true"`
|
||||
Weighted *WeightedRoundRobin `json:"weighted,omitempty" toml:"weighted,omitempty" yaml:"weighted,omitempty" label:"-" export:"true"`
|
||||
Mirroring *Mirroring `json:"mirroring,omitempty" toml:"mirroring,omitempty" yaml:"mirroring,omitempty" label:"-" export:"true"`
|
||||
Failover *Failover `json:"failover,omitempty" toml:"failover,omitempty" yaml:"failover,omitempty" label:"-" export:"true"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
|
|
@ -157,6 +158,19 @@ type WeightedRoundRobin struct {
|
|||
|
||||
// +k8s:deepcopy-gen=true
|
||||
|
||||
// HighestRandomWeight is a weighted sticky load-balancer of services.
|
||||
type HighestRandomWeight struct {
|
||||
Services []HRWService `json:"services,omitempty" toml:"services,omitempty" yaml:"services,omitempty" export:"true"`
|
||||
// HealthCheck enables automatic self-healthcheck for this service, i.e.
|
||||
// whenever one of its children is reported as down, this service becomes aware of it,
|
||||
// and takes it into account (i.e. it ignores the down child) when running the
|
||||
// load-balancing algorithm. In addition, if the parent of this service also has
|
||||
// HealthCheck enabled, this service reports to its parent any status change.
|
||||
HealthCheck *HealthCheck `json:"healthCheck,omitempty" toml:"healthCheck,omitempty" yaml:"healthCheck,omitempty" label:"allowEmpty" file:"allowEmpty" kv:"allowEmpty" export:"true"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
|
||||
// WRRService is a reference to a service load-balanced with weighted round-robin.
|
||||
type WRRService struct {
|
||||
Name string `json:"name,omitempty" toml:"name,omitempty" yaml:"name,omitempty" export:"true"`
|
||||
|
|
@ -170,6 +184,20 @@ type WRRService struct {
|
|||
GRPCStatus *GRPCStatus `json:"-" toml:"-" yaml:"-" label:"-" file:"-"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
|
||||
// HRWService is a reference to a service load-balanced with highest random weight.
|
||||
type HRWService struct {
|
||||
Name string `json:"name,omitempty" toml:"name,omitempty" yaml:"name,omitempty" export:"true"`
|
||||
Weight *int `json:"weight,omitempty" toml:"weight,omitempty" yaml:"weight,omitempty" export:"true"`
|
||||
}
|
||||
|
||||
// SetDefaults Default values for a HRWService.
|
||||
func (w *HRWService) SetDefaults() {
|
||||
defaultWeight := 1
|
||||
w.Weight = &defaultWeight
|
||||
}
|
||||
|
||||
// SetDefaults Default values for a WRRService.
|
||||
func (w *WRRService) SetDefaults() {
|
||||
defaultWeight := 1
|
||||
|
|
@ -231,6 +259,8 @@ const (
|
|||
BalancerStrategyWRR BalancerStrategy = "wrr"
|
||||
// BalancerStrategyP2C is the power of two choices strategy.
|
||||
BalancerStrategyP2C BalancerStrategy = "p2c"
|
||||
// BalancerStrategyHRW is the power of two choices strategy.
|
||||
BalancerStrategyHRW BalancerStrategy = "hrw"
|
||||
)
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue