Sentinel fault-tolerance middleware component

Use Sentinel middleware to guarantee the reliability and resiliency of your application

Sentinel is a powerful fault-tolerance component that takes “flow” as the breakthrough point and covers multiple fields including flow control, traffic shaping, concurrency limiting, circuit breaking, and adaptive system protection to guarantee the reliability and resiliency of microservices.

The Sentinel HTTP middleware enables Dapr to facilitate Sentinel’s powerful abilities to protect your application. You can refer to Sentinel Wiki for more details on Sentinel.

Component format

In the following definition, the maximum requests per second are set to 10:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: sentinel
  5. spec:
  6. type: middleware.http.sentinel
  7. version: v1
  8. metadata:
  9. - name: appName
  10. value: "nodeapp"
  11. - name: logDir
  12. value: "/var/tmp"
  13. - name: flowRules
  14. value: >-
  15. [
  16. {
  17. "resource": "POST:/v1.0/invoke/nodeapp/method/neworder",
  18. "threshold": 10,
  19. "tokenCalculateStrategy": 0,
  20. "controlBehavior": 0
  21. }
  22. ]

Spec metadata fields

FieldDetailsExample
appNamethe name of current running servicenodeapp
logDirthe log directory path/var/tmp/sentinel
flowRulesjson array of sentinel flow control rulesflow control rule
circuitBreakerRulesjson array of sentinel circuit breaker rulescircuit breaker rule
hotSpotParamRulesjson array of sentinel hotspot parameter flow control ruleshotspot rule
isolationRulesjson array of sentinel isolation rulesisolation rule
systemRulesjson array of sentinel system rulessystem rule

Once the limit is reached, the request will return HTTP Status code 429: Too Many Requests.

Special note to resource field in each rule’s definition. In Dapr, it follows the following format:

  1. POST/GET/PUT/DELETE:Dapr HTTP API Request Path

All concrete HTTP API information can be found from [Dapr API Reference]https://docs.dapr.io/reference/api/. In the above sample config, the resource field is set to POST:/v1.0/invoke/nodeapp/method/neworder.

Dapr configuration

To be applied, the middleware must be referenced in configuration. See middleware pipelines.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Configuration
  3. metadata:
  4. name: daprConfig
  5. spec:
  6. httpPipeline:
  7. handlers:
  8. - name: sentinel
  9. type: middleware.http.sentinel

Last modified June 24, 2021: upmerge/06-24 (#1588) (55d9123c)