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

What is the best practice to enable/disable the flow rule? #798

Closed
elvislou opened this issue May 29, 2019 · 5 comments
Closed

What is the best practice to enable/disable the flow rule? #798

elvislou opened this issue May 29, 2019 · 5 comments
Labels
kind/question Category issues related to questions or problems

Comments

@elvislou
Copy link

elvislou commented May 29, 2019

跟dubbo结合使用的时候,

有什么最好的方法,来动态的开启或者关闭这个限流的功能呢?

谢谢。

@sentinel-bot sentinel-bot added the kind/question Category issues related to questions or problems label May 29, 2019
@cdfive
Copy link
Collaborator

cdfive commented May 29, 2019

Sentinel 的理念是开发者只需要关注资源的定义,当资源定义成功后可以动态增加各种流控降级规则

因为规则可以动态增加、删除,使用动态数据源,在配置中心或者控制台把资源对应的规则删除了,就相当于关闭了。

参考:
https://github.com/alibaba/Sentinel/wiki/动态规则扩展

还可以通过Sentinel应用端支持的HTTP API命令也可以查看/打开/关闭Sentinel(需要依赖transport包)
查看 http://localhost:8719/getSwitch
打开 http://localhost:8719/setSwitch?value=true
关闭 http://localhost:8719/setSwitch?value=false
查看所有支持的API http://localhost:8719/api

@elvislou
Copy link
Author

@cdfive 谢谢你的解答。

比如说用Apollo来配置规则,需求是可以随时enable/disable这条规则,如果用增加/删除规则的方式来做,是不是太重了, 可否在规则上比如status的字段,来表示生效或者不生效?

另外关于全局开关,你提到的setSwitch的方式,需要在本地每台应用上去执行? 有没有办法做到跟apollo上的开关来结合,比如apollo上面开关关掉,那么整个dubbo集群的所有节点都关闭流控,只要一打开,所有节点就打开流控。

@cdfive
Copy link
Collaborator

cdfive commented May 30, 2019

通过status标识生效和不生效,这个问题之前在社区钉钉群里有讨论过。规则上之所以没有加状态字段是考虑到,让应用端内存中的规则是已生效的,这样效率会更高,记得大概是这样的。
启用/禁用规则,可以在控制台和动态数据源去做,目前暂时还没有这个功能,需要定制开发。
在阿里云的AHAS里的控制台里有这个功能。

全局开关的话
一种就是在控制台增加这个功能,对应用的单个节点以及应用的所有节点进行启用/禁用Sentinel;
另一种结合Apllo配置,可以在应用端做,根据配置的开关,代码里通过Constants.ON=true/false;
即可启用/禁用Sentinel。

@sczyh30 @CarpenterLee @jasonjoo2010
不确定这里回答的是否完全没问题,请帮忙看下。
关于规则生效和全局开关这2个需求有什么好的建议吗?

@jasonjoo2010
Copy link
Collaborator

这个是定制需求,正常业务一般不这么干,参考scm的版本历史,可以另外弄一套类似方案选择的外挂来处理。

@sczyh30
Copy link
Member

sczyh30 commented May 31, 2019

跟dubbo结合使用的时候,有什么最好的方法,来动态的开启或者关闭这个限流的功能呢?

规则本身没有开启/关闭状态,但推送的规则 JSON 里面可以有自定义字段,注册动态规则源的时候实现自定义的 Converter 来解析,把非开启状态的规则过滤掉即可。

@sczyh30 sczyh30 closed this as completed Jun 3, 2019
@sczyh30 sczyh30 changed the title What is the best practice to enable/disable flow controller when use with dubbo? What is the best practice to enable/disable the flow rule? Dec 19, 2019
CST11021 pushed a commit to CST11021/Sentinel that referenced this issue Nov 3, 2021
… in yaml config file dosen't work. (alibaba#798)

* [issue#790]fix defaultTopicPerm and defaultGroupPerm values which are in the yaml config file doesn't work.

* [issue#790]fix defaultTopicPerm and defaultGroupPerm doesn't work,fix the unit test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Category issues related to questions or problems
Projects
None yet
Development

No branches or pull requests

5 participants