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

请问关于配额设计是如何考虑的 以及如何修改配额 #229

Closed
five111 opened this issue Nov 29, 2021 · 2 comments
Closed

请问关于配额设计是如何考虑的 以及如何修改配额 #229

five111 opened this issue Nov 29, 2021 · 2 comments

Comments

@five111
Copy link

five111 commented Nov 29, 2021

func PreCreate(service, domain, project, resource string, number int64) error {
	if defaultManager == nil {
		openlog.Debug("quota management not available")
		return nil
	}
	qs, err := defaultManager.GetQuotas(service, domain, project)
	if err != nil {
		openlog.Error(err.Error())
		return ErrGetFailed
	}
	var resourceQuota *Quota
	for _, q := range qs {
		if q.ResourceName == resource {
			resourceQuota = q
			break
		}
	}
	if resourceQuota == nil {
		//no limits
		openlog.Debug("no limits for " + resource)
		return nil
	}
	if number > resourceQuota.Limit-resourceQuota.Used {
		return ErrReached
	}
	return nil
}

配额的维度是和 service , domain, project 相关的
这里的domain和project可以说是从请求参数中读取的
但是service这个 从命名来看是和服务挂钩的,这个维度在请求时该如何体现
做性能测试时 发现默认最大就10000, 这个配额该如何配置?

@five111
Copy link
Author

five111 commented Nov 29, 2021

补充一下 这边的实现是否需要考虑原子性 配额10000 我实际已经插入进去的配置为10082

{
	"version": "0.1.0",
	"revision": "10094",
	"timestamp": 1638175900,
	"total_kv_count": 10082
}

@tianxiaoliang
Copy link
Contributor

tianxiaoliang commented Dec 1, 2021

the impl is in here https://github.com/apache/servicecomb-kie/blob/master/server/plugin/qms/quota.go.

which means you can use env param to set quota.

would you like to contribute the doc?

quota managment will not introduce eventual consistency problem ,the answer is no, we will not gurantee that

@five111 five111 closed this as completed Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants