queryCoord的balancer分析

2023-12-11 17:36:31 浏览数 (1)

queryCoord的balancer分析

milvus版本:v2.3.2

涉及到一个参数设置:

代码语言:shell复制
queryCoord.balancer = ScoreBasedBalancer

milvus内置的balancer有3种:

代码位置:internalquerycoordv2balancebalance.go

代码语言:go复制
var (
	RoundRobinBalancerName    = "RoundRobinBalancer"
	RowCountBasedBalancerName = "RowCountBasedBalancer"
	ScoreBasedBalancerName    = "ScoreBasedBalancer"
)

Balance接口:

代码语言:go复制
type Balance interface {
	AssignSegment(collectionID int64, segments []*meta.Segment, nodes []int64) []SegmentAssignPlan
	AssignChannel(channels []*meta.DmChannel, nodes []int64) []ChannelAssignPlan
	BalanceReplica(replica *meta.Replica) ([]SegmentAssignPlan, []ChannelAssignPlan)
}

这个接口有3个实现。

ScoreBasedBalancer、RoundRobinBalancer、RowCountBasedBalancer。

代码语言:go复制
func (controller *CheckerController) check(ctx context.Context, checkerType string) {
	checker := controller.checkers[checkerType]
	tasks := checker.Check(ctx)

	for _, task := range tasks {
		err := controller.scheduler.Add(task)
		if err != nil {
			task.Cancel(err)
			continue
		}
	}
}

checker.Check()有4个实现,会调用AssignSegment、AssignChannel、BalanceReplica方法。

0 人点赞