alibaba / sentinel-golang

Sentinel Go enables reliability and resiliency for Go microservices
https://sentinelguard.io/
Apache License 2.0
2.76k stars 431 forks source link

System Guard flow control | CPU thredshold| 系统自适应流控|以CPU作为阈值场景下的取值范围问题 #538

Closed sunyucheng closed 1 year ago

sunyucheng commented 1 year ago

背景: 我在测试使用CPU作为阈值的系统自适应流控方案。 问题: 1、在 [func IsValidSystemRule(rule *Rule) error](https://github.com/alibaba/sentinel-golang/blob/08071855bc67423777353c6e02f1390b419172b1/core/system/rule_manager.go#L133C16-L133C16)中校验的 cpu取值范围为0.0~1.1。但是在实际测试中发现该处通过通过[func getProcessCpuStat() (float64, error)](https://github.com/alibaba/sentinel-golang/blob/08071855bc67423777353c6e02f1390b419172b1/core/system_metric/sys_metric_stat.go#L185C6-L185C23)函数在实际返回的数值大小为0.0~100.0。 该处是否应该修改一下cpu的合法性校验范围。