-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* sentinel middleware doc #1437 * update description * revise title * Update daprdocs/content/en/developing-applications/middleware/supported-middleware/middleware-sentinel.md * Update daprdocs/content/en/developing-applications/middleware/supported-middleware/middleware-sentinel.md Co-authored-by: Aaron Crawfis <Aaron.Crawfis@microsoft.com> Co-authored-by: Ori Zohar <orzohar@microsoft.com>
- Loading branch information
1 parent
5e30717
commit f910dfc
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
.../developing-applications/middleware/supported-middleware/middleware-sentinel.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
--- | ||
type: docs | ||
title: "Sentinel fault-tolerance middleware component" | ||
linkTitle: "Sentinel" | ||
weight: 7000 | ||
description: "Use Sentinel middleware to guarantee the reliability and resiliency of your application" | ||
--- | ||
|
||
[Sentinel](https://github.com/alibaba/sentinel-golang) 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]({{< ref middleware-concept.md >}}) enables Dapr to facilitate Sentinel's powerful abilities to protect your application. You can refer to [Sentinel Wiki](https://github.com/alibaba/sentinel-golang/wiki) for more details on Sentinel. | ||
|
||
## Component format | ||
|
||
In the following definition, the maximum requests per second are set to 10: | ||
|
||
```yaml | ||
apiVersion: dapr.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: sentinel | ||
spec: | ||
type: middleware.http.sentinel | ||
version: v1 | ||
metadata: | ||
- name: appName | ||
value: "nodeapp" | ||
- name: logDir | ||
value: "/var/tmp" | ||
- name: flowRules | ||
value: >- | ||
[ | ||
{ | ||
"resource": "POST:/v1.0/invoke/nodeapp/method/neworder", | ||
"threshold": 10, | ||
"tokenCalculateStrategy": 0, | ||
"controlBehavior": 0 | ||
} | ||
] | ||
``` | ||
|
||
## Spec metadata fields | ||
|
||
| Field | Details | Example | | ||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------| | ||
| appName | the name of current running service | `nodeapp` | | ||
| logDir | the log directory path | `/var/tmp/sentinel` | | ||
| flowRules | json array of sentinel flow control rules | [flow control rule](https://github.com/alibaba/sentinel-golang/blob/master/core/flow/rule.go) | | ||
| circuitBreakerRules | json array of sentinel circuit breaker rules | [circuit breaker rule](https://github.com/alibaba/sentinel-golang/blob/master/core/circuitbreaker/rule.go) | | ||
| hotSpotParamRules | json array of sentinel hotspot parameter flow control rules | [hotspot rule](https://github.com/alibaba/sentinel-golang/blob/master/core/hotspot/rule.go) | | ||
| isolationRules | json array of sentinel isolation rules | [isolation rule](https://github.com/alibaba/sentinel-golang/blob/master/core/isolation/rule.go) | | ||
| systemRules | json array of sentinel system rules | [system rule](https://github.com/alibaba/sentinel-golang/blob/master/core/system/rule.go) | | ||
|
||
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: | ||
|
||
``` | ||
POST/GET/PUT/DELETE:Dapr HTTP API Request Path | ||
``` | ||
|
||
All concrete HTTP API information can be found from [Dapr API Reference]{{< ref "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]({{< ref configuration-concept.md >}}). See [middleware pipelines]({{< ref "middleware-concept.md#customize-processing-pipeline">}}). | ||
|
||
```yaml | ||
apiVersion: dapr.io/v1alpha1 | ||
kind: Configuration | ||
metadata: | ||
name: daprConfig | ||
spec: | ||
httpPipeline: | ||
handlers: | ||
- name: sentinel | ||
type: middleware.http.sentinel | ||
``` | ||
|
||
## Related links | ||
|
||
- [Sentinel Github](https://github.com/alibaba/sentinel-golang) | ||
- [Middleware concept]({{< ref middleware-concept.md >}}) | ||
- [Dapr configuration]({{< ref configuration-concept.md >}}) | ||
- [Configuration overview]({{< ref configuration-overview.md >}}) |