Skip to content

Dynamic Rule Configuration

jialianglinjl edited this page Jun 25, 2018 · 9 revisions

All the rules can be queried or modified in memory and these modifications take effects immediately. And Sentinel also provides APIs for developers to defines its own rules.

Rule definitions

There are 3 kinds of rules: Flow rules, degrade rules, system rules.

1.Flow Rules

Flow Rule has following fields:

field description default value
resource resource name
count thredshold
grade depends on QPS or concurrency(active thread count) QPS
limitApp whether to count on callers no
strategy count on the resource itself; or on the relate resource(refResource),or on entry resource(refResource) resource itself
controlBehavior how to action after block criteria is met, to block immediately, or wait in queue, or slow warm up block immediatley

One resource can apply several rules

2.Degrade Rule Degrade has following fields:

field description default value
resource resource name
count thredshold
grade down grade o RT or qps RT
timeWindow timewindow when degradation happens

3.系统保护规则

query active rules

Run following command to query current active rules:

curl http://localhost:8719/getRules?type=? ,type=flow will return all flow rules in JSON format;degrade will return all degrade rule in JSON format;and system will return system rules.

modify rules

we can modify following rules via following command:

curl http://localhost:8719/setRules?type=&data=,data is the rules in JSON format.

Customize your persistent rules

All the rules configuration above are stored in memory, which means that rules will be lost if the application restart. Developer can implement DataSource to define his own persist rule logic.

  1. Via Diamond. Sample can refer to: Diamond
  2. Via SQL,GitHub, Sample ca refer to [TODO]
  3. Via Dashboard, sample can refer to [TODO]
Clone this wiki locally