Documentation ¶
Index ¶
- Variables
- func AssignedResources(a *Assignment) []string
- func HasReplica(s *Slice, resource string) bool
- func Replicas(s *Slice) []string
- type AlgoConstraints
- func (*AlgoConstraints) Descriptor() ([]byte, []int)deprecated
- func (x *AlgoConstraints) GetDereplicateThreshold() float64
- func (x *AlgoConstraints) GetMaxLoadLimitResource() float64
- func (x *AlgoConstraints) GetMaxNumSlicesResourceHint() int64
- func (x *AlgoConstraints) GetMinLoadLimitResource() float64
- func (x *AlgoConstraints) GetReplicateThreshold() float64
- func (x *AlgoConstraints) GetSplitThreshold() float64
- func (*AlgoConstraints) ProtoMessage()
- func (x *AlgoConstraints) ProtoReflect() protoreflect.Message
- func (x *AlgoConstraints) Reset()
- func (x *AlgoConstraints) String() string
- type Algorithm
- type Assigner
- func (a *Assigner) GetComponentsToStart(req *nanny.GetComponentsRequest) (*nanny.GetComponentsReply, error)
- func (a *Assigner) GetReplicaSets(ctx context.Context, req *nanny.GetReplicaSetsRequest) (*nanny.GetReplicaSetsReply, error)
- func (a *Assigner) GetRoutingInfo(req *nanny.GetRoutingRequest) (*nanny.GetRoutingReply, error)
- func (a *Assigner) RegisterComponent(ctx context.Context, req *nanny.ActivateComponentRequest) error
- func (a *Assigner) RegisterListener(ctx context.Context, req *nanny.ExportListenerRequest) error
- func (a *Assigner) StopAppVersion(ctx context.Context, app, appVersion string) error
- type Assignment
- func (*Assignment) Descriptor() ([]byte, []int)deprecated
- func (x *Assignment) GetCandidateResources() map[string]bool
- func (x *Assignment) GetConstraints() *AlgoConstraints
- func (x *Assignment) GetSlices() []*Slice
- func (x *Assignment) GetStats() *Statistics
- func (x *Assignment) GetVersion() uint64
- func (*Assignment) ProtoMessage()
- func (x *Assignment) ProtoReflect() protoreflect.Message
- func (x *Assignment) Reset()
- func (x *Assignment) String() string
- type LoadTracker
- func (*LoadTracker) Descriptor() ([]byte, []int)deprecated
- func (x *LoadTracker) GetDistribution() map[uint64]float64
- func (x *LoadTracker) GetPerResourceLoad() float64
- func (x *LoadTracker) GetResources() map[string]bool
- func (*LoadTracker) ProtoMessage()
- func (x *LoadTracker) ProtoReflect() protoreflect.Message
- func (x *LoadTracker) Reset()
- func (x *LoadTracker) String() string
- type ReplicaSetState
- func (*ReplicaSetState) Descriptor() ([]byte, []int)deprecated
- func (x *ReplicaSetState) GetReplicaSet() *nanny.ReplicaSet
- func (x *ReplicaSetState) GetRoutingAssignments() map[string]*Assignment
- func (*ReplicaSetState) ProtoMessage()
- func (x *ReplicaSetState) ProtoReflect() protoreflect.Message
- func (x *ReplicaSetState) Reset()
- func (x *ReplicaSetState) String() string
- type Slice
- func (*Slice) Descriptor() ([]byte, []int)deprecated
- func (x *Slice) GetEndExclusive() *SliceKey
- func (x *Slice) GetLoadInfo() *LoadTracker
- func (x *Slice) GetStartInclusive() *SliceKey
- func (*Slice) ProtoMessage()
- func (x *Slice) ProtoReflect() protoreflect.Message
- func (x *Slice) Reset()
- func (x *Slice) String() string
- type SliceKey
- type Statistics
- func (*Statistics) Descriptor() ([]byte, []int)deprecated
- func (x *Statistics) GetDereplicateOps() int64
- func (x *Statistics) GetMergeOps() int64
- func (x *Statistics) GetMoveDueToBalanceOps() int64
- func (x *Statistics) GetMoveDueToUnhealthyOps() int64
- func (x *Statistics) GetReplicateOps() int64
- func (x *Statistics) GetSplitOps() int64
- func (*Statistics) ProtoMessage()
- func (x *Statistics) ProtoReflect() protoreflect.Message
- func (x *Statistics) Reset()
- func (x *Statistics) String() string
Constants ¶
This section is empty.
Variables ¶
var File_internal_nanny_assigner_assigner_proto protoreflect.FileDescriptor
Functions ¶
func AssignedResources ¶
func AssignedResources(a *Assignment) []string
AssignedResources returns all the resources assigned to the entire key space in a given assignment.
func HasReplica ¶
Types ¶
type AlgoConstraints ¶
type AlgoConstraints struct { // Upper bound on the load allowed on any resource. MaxLoadLimitResource float64 `` /* 127-byte string literal not displayed */ // Lower bound on the load allowed on any resource. MinLoadLimitResource float64 `` /* 127-byte string literal not displayed */ // Any slice with replica load above this threshold should be split to enable // the algo to move slices around, in order to provide load balancing // guarantees. SplitThreshold float64 `protobuf:"fixed64,3,opt,name=split_threshold,json=splitThreshold,proto3" json:"split_threshold,omitempty"` // Any slice with replica load above this threshold should be replicated to // enable the algo to move slices around, in order to provide load balancing // guarantees. // // In practice, this threshold should be set to a value equal to or higher // than the splitThreshold, because it is preferred for a slice to be split // first. // // Also, a good algorithm should replicate a slice iff the slice has a single // key; otherwise splitting is always preferred because it incurs less churn. ReplicateThreshold float64 `protobuf:"fixed64,4,opt,name=replicate_threshold,json=replicateThreshold,proto3" json:"replicate_threshold,omitempty"` // Any slice with replica load below this threshold should be dereplicated if // the number of replicas is greater than 1. // // Dereplication creates more opportunities for merging slices, hence // controlling the assignment size. DereplicateThreshold float64 `protobuf:"fixed64,5,opt,name=dereplicate_threshold,json=dereplicateThreshold,proto3" json:"dereplicate_threshold,omitempty"` // Maximum number of slices a resource should be assigned in a given // assignment. Note that this is just a hint, because in reality the algorithm // might not be able to provide a hard guarantee. // // The role of this constraint is to ensure that the number of slices in an // assignment is bounded. MaxNumSlicesResourceHint int64 `` /* 140-byte string literal not displayed */ // contains filtered or unexported fields }
AlgoConstraints contains various constraints needed by the routing algos to generate assignments.
func (*AlgoConstraints) Descriptor
deprecated
func (*AlgoConstraints) Descriptor() ([]byte, []int)
Deprecated: Use AlgoConstraints.ProtoReflect.Descriptor instead.
func (*AlgoConstraints) GetDereplicateThreshold ¶
func (x *AlgoConstraints) GetDereplicateThreshold() float64
func (*AlgoConstraints) GetMaxLoadLimitResource ¶
func (x *AlgoConstraints) GetMaxLoadLimitResource() float64
func (*AlgoConstraints) GetMaxNumSlicesResourceHint ¶
func (x *AlgoConstraints) GetMaxNumSlicesResourceHint() int64
func (*AlgoConstraints) GetMinLoadLimitResource ¶
func (x *AlgoConstraints) GetMinLoadLimitResource() float64
func (*AlgoConstraints) GetReplicateThreshold ¶
func (x *AlgoConstraints) GetReplicateThreshold() float64
func (*AlgoConstraints) GetSplitThreshold ¶
func (x *AlgoConstraints) GetSplitThreshold() float64
func (*AlgoConstraints) ProtoMessage ¶
func (*AlgoConstraints) ProtoMessage()
func (*AlgoConstraints) ProtoReflect ¶
func (x *AlgoConstraints) ProtoReflect() protoreflect.Message
func (*AlgoConstraints) Reset ¶
func (x *AlgoConstraints) Reset()
func (*AlgoConstraints) String ¶
func (x *AlgoConstraints) String() string
type Algorithm ¶
type Algorithm func(currAssignment *Assignment) (*Assignment, error)
Algorithm takes the current assignment, and returns a new assignment. The returned assignment should have a larger version than the current assignment.
type Assigner ¶
type Assigner struct {
// contains filtered or unexported fields
}
Assigner generates routing information for a set of managed Kubernetes ReplicaSets.
In the current implementation, the assigner generates new routing information when (1) new components become managed by the ReplicaSet, or (2) the load changes for a given Pod, or (3) the ReplicaSet acquires new Pods.
func NewAssigner ¶
func (*Assigner) GetComponentsToStart ¶
func (a *Assigner) GetComponentsToStart(req *nanny.GetComponentsRequest) (*nanny.GetComponentsReply, error)
GetComponentsToStart returns the set of components the given replica set should start. This call will block if there have been no component changes since the last call to GetComponentsToStart().
func (*Assigner) GetReplicaSets ¶ added in v0.22.1
func (a *Assigner) GetReplicaSets(ctx context.Context, req *nanny.GetReplicaSetsRequest) (*nanny.GetReplicaSetsReply, error)
GetReplicaSets returns the state of all Kubernetes ReplicaSets for an application version or a collection of applications and their versions.
func (*Assigner) GetRoutingInfo ¶
func (a *Assigner) GetRoutingInfo(req *nanny.GetRoutingRequest) (*nanny.GetRoutingReply, error)
GetRoutingInfo returns the routing information for a given component. This call will block if there have been no routing changes since the last call to GetRoutingInfo().
func (*Assigner) RegisterComponent ¶ added in v0.22.1
func (a *Assigner) RegisterComponent(ctx context.Context, req *nanny.ActivateComponentRequest) error
RegisterComponent registers a given activated component.
func (*Assigner) RegisterListener ¶
RegisterListener registers a given instantiated listener.
func (*Assigner) StopAppVersion ¶ added in v0.22.1
StopAppVersion stops all work for the given app version and cleans up its state.
If the method returns an error, it should be invoked again as the operation likely hasn't been fully applied.
TODO(mwhittaker): The store deletions below race any operations that write to the store. We should make sure that every operation that could potentially write to the store first checks to see if the version has been stopped. This is complicated by the fact that the store writes are spread between the assigner, manager, the gke deployer, and the gke-local deployer.
type Assignment ¶
type Assignment struct { Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` Slices []*Slice `protobuf:"bytes,2,rep,name=slices,proto3" json:"slices,omitempty"` CandidateResources map[string]bool `` /* 204-byte string literal not displayed */ Constraints *AlgoConstraints `protobuf:"bytes,4,opt,name=constraints,proto3" json:"constraints,omitempty"` Stats *Statistics `protobuf:"bytes,5,opt,name=stats,proto3" json:"stats,omitempty"` // contains filtered or unexported fields }
Assignment is a wrapper class that creates and decodes assignment protos.
func EqualDistributionAlgorithm ¶
func EqualDistributionAlgorithm(currAssignment *Assignment) (*Assignment, error)
EqualDistributionAlgorithm is an implementation of a sharding algorithm that distributes the entire key space approximately equally across all healthy resources.
The algorithm is as follows: - split the entire key space in a number of slices that is more likely to spread uniformly the key space among all healthy resources
- distribute the slices round robin across all healthy resources
func FromProto ¶
func FromProto(assignmentP *protos.Assignment) (*Assignment, error)
FromProto returns an assignment from an assignment proto.
func LoadBasedAlgorithm ¶
func LoadBasedAlgorithm(currAssignment *Assignment) (*Assignment, error)
LoadBasedAlgorithm is an implementation of a sharding algorithm that attempts to minimize the maximum load on any given resource.
func (*Assignment) Descriptor
deprecated
func (*Assignment) Descriptor() ([]byte, []int)
Deprecated: Use Assignment.ProtoReflect.Descriptor instead.
func (*Assignment) GetCandidateResources ¶
func (x *Assignment) GetCandidateResources() map[string]bool
func (*Assignment) GetConstraints ¶
func (x *Assignment) GetConstraints() *AlgoConstraints
func (*Assignment) GetSlices ¶
func (x *Assignment) GetSlices() []*Slice
func (*Assignment) GetStats ¶
func (x *Assignment) GetStats() *Statistics
func (*Assignment) GetVersion ¶
func (x *Assignment) GetVersion() uint64
func (*Assignment) ProtoMessage ¶
func (*Assignment) ProtoMessage()
func (*Assignment) ProtoReflect ¶
func (x *Assignment) ProtoReflect() protoreflect.Message
func (*Assignment) Reset ¶
func (x *Assignment) Reset()
func (*Assignment) String ¶
func (x *Assignment) String() string
type LoadTracker ¶
type LoadTracker struct { // Slice load on a given resource. PerResourceLoad float64 `protobuf:"fixed64,1,opt,name=per_resource_load,json=perResourceLoad,proto3" json:"per_resource_load,omitempty"` // Resources to which the slice is assigned. Resources map[string]bool `` /* 160-byte string literal not displayed */ // Distribution of the load along split points. Distribution map[uint64]float64 `` /* 168-byte string literal not displayed */ // contains filtered or unexported fields }
loadTracker tracks load information for a given slice across all the assigned resources.
Note that for a replicated slice (len(resources) > 1):
- perResourceload contains the total load as reported by the latest resource that has the slice assigned
- distribution contains the load distribution along split points for the given replica
Most of the slices will have a single replica; ideally, only hot keys should be replicated. Given that our load metric is req/s it is fair to assume that the load is evenly distributed across the replicas of a slice, hence the load, and the load distribution for a given replica should be representative for all replicas. Otherwise, it is challenging for the weavelets to report exactly the same split points for all replicas, and challenging for the assigner to compute split points that make sense across all replicas.
TODO(rgrandl): mwhittaker@ has an interesting idea. Instead of taking the latest load report, we take the load report with the largest number of requests received. That way if a resource was down for some reason or lagging behind in an assignment and reports an almost empty load report, we won't use it.
TODO(rgrandl): revisit these decisions if we ever decide to support a different load metric.
func (*LoadTracker) Descriptor
deprecated
func (*LoadTracker) Descriptor() ([]byte, []int)
Deprecated: Use LoadTracker.ProtoReflect.Descriptor instead.
func (*LoadTracker) GetDistribution ¶
func (x *LoadTracker) GetDistribution() map[uint64]float64
func (*LoadTracker) GetPerResourceLoad ¶
func (x *LoadTracker) GetPerResourceLoad() float64
func (*LoadTracker) GetResources ¶
func (x *LoadTracker) GetResources() map[string]bool
func (*LoadTracker) ProtoMessage ¶
func (*LoadTracker) ProtoMessage()
func (*LoadTracker) ProtoReflect ¶
func (x *LoadTracker) ProtoReflect() protoreflect.Message
func (*LoadTracker) Reset ¶
func (x *LoadTracker) Reset()
func (*LoadTracker) String ¶
func (x *LoadTracker) String() string
type ReplicaSetState ¶ added in v0.2.0
type ReplicaSetState struct { ReplicaSet *nanny.ReplicaSet `protobuf:"bytes,1,opt,name=replica_set,json=replicaSet,proto3" json:"replica_set,omitempty"` // Routing assignments for all components that use routing/sharding, keyed // by component name. RoutingAssignments map[string]*Assignment `` /* 203-byte string literal not displayed */ // contains filtered or unexported fields }
ReplicaSetState stores information about a Kubernetes ReplicaSet, i.e., a set of pods that host the same set of components.
func (*ReplicaSetState) Descriptor
deprecated
added in
v0.2.0
func (*ReplicaSetState) Descriptor() ([]byte, []int)
Deprecated: Use ReplicaSetState.ProtoReflect.Descriptor instead.
func (*ReplicaSetState) GetReplicaSet ¶ added in v0.22.1
func (x *ReplicaSetState) GetReplicaSet() *nanny.ReplicaSet
func (*ReplicaSetState) GetRoutingAssignments ¶ added in v0.22.1
func (x *ReplicaSetState) GetRoutingAssignments() map[string]*Assignment
func (*ReplicaSetState) ProtoMessage ¶ added in v0.2.0
func (*ReplicaSetState) ProtoMessage()
func (*ReplicaSetState) ProtoReflect ¶ added in v0.2.0
func (x *ReplicaSetState) ProtoReflect() protoreflect.Message
func (*ReplicaSetState) Reset ¶ added in v0.2.0
func (x *ReplicaSetState) Reset()
func (*ReplicaSetState) String ¶ added in v0.2.0
func (x *ReplicaSetState) String() string
type Slice ¶
type Slice struct { StartInclusive *SliceKey `protobuf:"bytes,1,opt,name=start_inclusive,json=startInclusive,proto3" json:"start_inclusive,omitempty"` EndExclusive *SliceKey `protobuf:"bytes,2,opt,name=end_exclusive,json=endExclusive,proto3" json:"end_exclusive,omitempty"` LoadInfo *LoadTracker `protobuf:"bytes,3,opt,name=load_info,json=loadInfo,proto3" json:"load_info,omitempty"` // contains filtered or unexported fields }
Slice contains the allocation of a routing key range to a set of resources.
The range covers [startInclusive, endExclusive).
func (*Slice) Descriptor
deprecated
func (*Slice) GetEndExclusive ¶
func (*Slice) GetLoadInfo ¶
func (x *Slice) GetLoadInfo() *LoadTracker
func (*Slice) GetStartInclusive ¶
func (*Slice) ProtoMessage ¶
func (*Slice) ProtoMessage()
func (*Slice) ProtoReflect ¶
func (x *Slice) ProtoReflect() protoreflect.Message
type SliceKey ¶
type SliceKey struct { Val uint64 `protobuf:"varint,1,opt,name=val,proto3" json:"val,omitempty"` // contains filtered or unexported fields }
SliceKey is an abstraction for routing keys used in slices.
func (*SliceKey) Descriptor
deprecated
func (*SliceKey) ProtoMessage ¶
func (*SliceKey) ProtoMessage()
func (*SliceKey) ProtoReflect ¶
func (x *SliceKey) ProtoReflect() protoreflect.Message
type Statistics ¶
type Statistics struct { SplitOps int64 `protobuf:"varint,1,opt,name=splitOps,proto3" json:"splitOps,omitempty"` MergeOps int64 `protobuf:"varint,2,opt,name=mergeOps,proto3" json:"mergeOps,omitempty"` ReplicateOps int64 `protobuf:"varint,3,opt,name=replicateOps,proto3" json:"replicateOps,omitempty"` DereplicateOps int64 `protobuf:"varint,4,opt,name=dereplicateOps,proto3" json:"dereplicateOps,omitempty"` MoveDueToBalanceOps int64 `protobuf:"varint,5,opt,name=moveDueToBalanceOps,proto3" json:"moveDueToBalanceOps,omitempty"` MoveDueToUnhealthyOps int64 `protobuf:"varint,6,opt,name=moveDueToUnhealthyOps,proto3" json:"moveDueToUnhealthyOps,omitempty"` // contains filtered or unexported fields }
Statistics contains various statistics for a given assignment.
func (*Statistics) Descriptor
deprecated
func (*Statistics) Descriptor() ([]byte, []int)
Deprecated: Use Statistics.ProtoReflect.Descriptor instead.
func (*Statistics) GetDereplicateOps ¶
func (x *Statistics) GetDereplicateOps() int64
func (*Statistics) GetMergeOps ¶
func (x *Statistics) GetMergeOps() int64
func (*Statistics) GetMoveDueToBalanceOps ¶
func (x *Statistics) GetMoveDueToBalanceOps() int64
func (*Statistics) GetMoveDueToUnhealthyOps ¶
func (x *Statistics) GetMoveDueToUnhealthyOps() int64
func (*Statistics) GetReplicateOps ¶
func (x *Statistics) GetReplicateOps() int64
func (*Statistics) GetSplitOps ¶
func (x *Statistics) GetSplitOps() int64
func (*Statistics) ProtoMessage ¶
func (*Statistics) ProtoMessage()
func (*Statistics) ProtoReflect ¶
func (x *Statistics) ProtoReflect() protoreflect.Message
func (*Statistics) Reset ¶
func (x *Statistics) Reset()
func (*Statistics) String ¶
func (x *Statistics) String() string