Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General Design for Metrics(memory、cpu...) adaptive flow control #368

Open
louyuting opened this issue Dec 30, 2020 · 2 comments · May be fixed by #387
Open

General Design for Metrics(memory、cpu...) adaptive flow control #368

louyuting opened this issue Dec 30, 2020 · 2 comments · May be fixed by #387
Labels
area/flow-control Issues or PRs related to flow control kind/discussion For further discussion priority/high Very important, need to be worked with soon but not very urgent
Milestone

Comments

@louyuting
Copy link
Collaborator

Issue Description

Type: feature request

Describe what feature you want

Additional context

refer to #348
Add any other context or screenshots about the feature request here.

@louyuting louyuting added area/flow-control Issues or PRs related to flow control kind/discussion For further discussion labels Dec 30, 2020
@louyuting louyuting added this to the 1.1.0 milestone Jan 24, 2021
@liqiangz
Copy link
Contributor

liqiangz commented Jan 26, 2021

自适应模块抽象方案

1.新建 adaptive 模块,可以做一些 ratio 相关的 adjustment.

type AdaptiveConfig struct {
	//用户自定义名称
	AdaptiveConfigName string
	//自适应类型,cpu、mem...
	AdaptiveType  AdaptiveType
	
	//相应自适应类型所需要的参数
	LowRatio      float64
	HighRatio     float64
	LowWaterMark  float64
	HighWaterMark float64
}

// 根据用户配置生成的 AdaptiveController
type AdaptiveController interface {
        //根据用户配置的系统自适应规则来做adjustment
	CalculateSystemAdaptiveCount(count float64) float64
}

var adaptiveControllerMap map[string]*AdaptiveController

//获取指定的 AdaptiveController
func GetAdaptiveController(adaptiveName string) *AdaptiveController {
}

//加载自适应配置
func LoadAdaptiveConfig(configs []*AdaptiveConfig) (bool, error){
}
  1. flow模块修改
//添加字段 AdaptiveConfigName,用于指定配置的自适应规则
type Rule struct {
...
AdaptiveConfigName string
...
}

//修改 DirectTrafficShapingCalculator 如下, 目前自适应仅支持 Direct 的 Token 计算策略
func (d *DirectTrafficShapingCalculator) CalculateAllowedTokens(uint32, int32) float64 {
	if d.owner.rule.AdaptiveConfigName != ""{
		 ac := adaptive.GetAdaptiveController(d.owner.rule.AdaptiveConfigName)
                 if ac != nil {
                    return ac.CalculateSystemAdaptiveCount(d.threshold)
                 }
	}
	return d.threshold
}

@louyuting
Copy link
Collaborator Author

louyuting commented Jan 28, 2021

It's basically OK to me

@louyuting louyuting added the priority/high Very important, need to be worked with soon but not very urgent label Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/flow-control Issues or PRs related to flow control kind/discussion For further discussion priority/high Very important, need to be worked with soon but not very urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants