Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Thumbs.db

# flattened pom file
.flattened-pom.xml
node_modules/
8 changes: 2 additions & 6 deletions sentinel-adapter/sentinel-apache-httpclient-adapter/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sentinel Apache Httpclient Adapter
# Sentinel Apache Httpclient Adapter

## Introduction

Expand Down Expand Up @@ -32,11 +32,7 @@ CloseableHttpClient httpclient = builder.build();

- `SentinelApacheHttpClientConfig` configuration:

| name | description | type | default value |
|------|------------|------|-------|
| prefix | customize resource prefix | `String` | `httpclient:` |
| extractor | customize resource extractor | `ApacheHttpClientResourceExtractor` | `DefaultApacheHttpClientResourceExtractor` |
| fallback | handle request when it is blocked | `ApacheHttpClientFallback` | `DefaultApacheHttpClientFallback` |
|name|description|type|default value||------|------------|------|-------||prefix|customize resource prefix|`String`|`httpclient:`||extractor|customize resource extractor|`ApacheHttpClientResourceExtractor`|`DefaultApacheHttpClientResourceExtractor`||fallback|handle request when it is blocked|`ApacheHttpClientFallback`|`DefaultApacheHttpClientFallback`|

### extractor (resource extractor)

Expand Down
8 changes: 2 additions & 6 deletions sentinel-adapter/sentinel-okhttp-adapter/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sentinel OkHttp Adapter
# Sentinel OkHttp Adapter

## Introduction

Expand Down Expand Up @@ -26,11 +26,7 @@ OkHttpClient client = new OkHttpClient.Builder()

`SentinelOkHttpConfig` configuration:

| name | description | type | default value |
|------|------------|------|-------|
| resourcePrefix | customized resource name prefix | `String` | `okhttp:` |
| resourceExtractor | customized resource extractor | `OkHttpResourceExtractor` | `DefaultOkHttpResourceExtractor` |
| fallback | handle request when it is blocked | `OkHttpFallback` | `DefaultOkHttpFallback` |
|name|description|type|default value||------|------------|------|-------||resourcePrefix|customized resource name prefix|`String`|`okhttp:`||resourceExtractor|customized resource extractor|`OkHttpResourceExtractor`|`DefaultOkHttpResourceExtractor`||fallback|handle request when it is blocked|`OkHttpFallback`|`DefaultOkHttpFallback`|

### Resource Extractor

Expand Down
28 changes: 14 additions & 14 deletions sentinel-adapter/sentinel-spring-webmvc-adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,23 @@ config.setBlockExceptionHandler((request, response, e) -> {

- Common configuration in `SentinelWebMvcConfig` and `SentinelWebMvcTotalConfig`:

| name | description | type | default value |
|------|------------|------|-------|
| `blockExceptionHandler`| The handler that handles the block request | `BlockExceptionHandler` | null (throw out the BlockException) |
| `originParser` | Extracting request origin (e.g. IP or appName from HTTP Header) from HTTP request | `RequestOriginParser` | - |
| name | description | type | default value |
| ------ | ------------ | ------ | ------- |
| `blockExceptionHandler` | The handler that handles the block request | `BlockExceptionHandler` | null (throw out the BlockException) |
| `originParser` | Extracting request origin (e.g. IP or appName from HTTP Header) from HTTP request | `RequestOriginParser` | - |

- `SentinelWebMvcConfig` configuration:

| name | description | type | default value |
|------|------------|------|-------|
| urlCleaner | The `UrlCleaner` interface is designed for clean and unify the URL resource. | `UrlCleaner` | - |
| requestAttributeName | Attribute key in request used by Sentinel (internal) | `String` | `$$sentinel_spring_web_entry_attr` |
| httpMethodSpecify | Specify whether the URL resource name should contain the HTTP method prefix (e.g. `POST:`). | `boolean` | `false` |
| webContextUnify | Specify whether unify web context(i.e. use the default context name). | `boolean` | `true` |
| name | description | type | default value |
| ------ | ------------ | ------ | ------- |
| urlCleaner | The `UrlCleaner` interface is designed for clean and unify the URL resource. | `UrlCleaner` | - |
| requestAttributeName | Attribute key in request used by Sentinel (internal) | `String` | `$$sentinel_spring_web_entry_attr` |
| httpMethodSpecify | Specify whether the URL resource name should contain the HTTP method prefix (e.g. `POST:`). | `boolean` | `false` |
| webContextUnify | Specify whether unify web context(i.e. use the default context name). | `boolean` | `true` |

- `SentinelWebMvcTotalConfig` configuration:

| name | description | type | default value |
|------|------------|------|-------|
| totalResourceName | The resource name in `SentinelTotalInterceptor` | `String` | `spring-mvc-total-url-request` |
| requestAttributeName | Attribute key in request used by Sentinel (internal) | `String` | `$$sentinel_spring_web_total_entry_attr` |
| name | description | type | default value |
| ------ | ------------ | ------ | ------- |
| totalResourceName | The resource name in `SentinelTotalInterceptor` | `String` | `spring-mvc-total-url-request` |
| requestAttributeName | Attribute key in request used by Sentinel (internal) | `String` | `$$sentinel_spring_web_total_entry_attr` |
8 changes: 4 additions & 4 deletions sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ config.setBlockExceptionHandler((request, response, e) -> {
- Common configuration in `SentinelWebMvcConfig` and `SentinelWebMvcTotalConfig`:

| name | description | type | default value |
|------|------------|------|-------|
| `blockExceptionHandler`| The handler that handles the block request | `BlockExceptionHandler` | null (throw out the BlockException) |
| ------ | ------------ | ------ | ------- |
| `blockExceptionHandler` | The handler that handles the block request | `BlockExceptionHandler` | null (throw out the BlockException) |
| `originParser` | Extracting request origin (e.g. IP or appName from HTTP Header) from HTTP request | `RequestOriginParser` | - |

- `SentinelWebMvcConfig` configuration:

| name | description | type | default value |
|------|------------|------|-------|
| ------ | ------------ | ------ | ------- |
| urlCleaner | The `UrlCleaner` interface is designed for clean and unify the URL resource. | `UrlCleaner` | - |
| requestAttributeName | Attribute key in request used by Sentinel (internal) | `String` | `$$sentinel_spring_web_entry_attr` |
| httpMethodSpecify | Specify whether the URL resource name should contain the HTTP method prefix (e.g. `POST:`). | `boolean` | `false` |
Expand All @@ -102,6 +102,6 @@ config.setBlockExceptionHandler((request, response, e) -> {
- `SentinelWebMvcTotalConfig` configuration:

| name | description | type | default value |
|------|------------|------|-------|
| ------ | ------------ | ------ | ------- |
| totalResourceName | The resource name in `SentinelTotalInterceptor` | `String` | `spring-mvc-total-url-request` |
| requestAttributeName | Attribute key in request used by Sentinel (internal) | `String` | `$$sentinel_spring_web_total_entry_attr` |
10 changes: 5 additions & 5 deletions sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ We may also retrieve the converted `FlowRule` via the command API `localhost:871

The configuration list:

| Item (env) | Item (JVM property) | Description | Default Value | Required |
|--------|--------|--------|--------|--------|
| `SENTINEL_RLS_GRPC_PORT` | `csp.sentinel.grpc.server.port` | The RLS gRPC server port | **10240** | false |
| `SENTINEL_RLS_RULE_FILE_PATH` | `csp.sentinel.rls.rule.file` | The path of the RLS rule yaml file | - | **true** |
| `SENTINEL_RLS_ACCESS_LOG` | - | Whether to enable the access log (`on` for enable) | off | false |
| Item (env) | Item (JVM property) | Description | Default Value | Required |
| -------- | -------- | -------- | -------- | -------- |
| `SENTINEL_RLS_GRPC_PORT` | `csp.sentinel.grpc.server.port` | The RLS gRPC server port | **10240** | false |
| `SENTINEL_RLS_RULE_FILE_PATH` | `csp.sentinel.rls.rule.file` | The path of the RLS rule yaml file | - | **true** |
| `SENTINEL_RLS_ACCESS_LOG` | - | Whether to enable the access log (`on` for enable) | off | false |

## Samples

Expand Down
8 changes: 4 additions & 4 deletions sentinel-dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ java -Dserver.port=8080 \
为便于演示,我们对控制台本身加入了流量控制功能,具体做法是引入 Sentinel 提供的 `CommonFilter` 这个 Servlet Filter。
上述 JVM 参数的含义是:

| 参数 | 作用 |
|--------|--------|
|`-Dcsp.sentinel.dashboard.server=localhost:8080`|向 Sentinel 接入端指定控制台的地址|
|`-Dproject.name=sentinel-dashboard`|向 Sentinel 指定应用名称,比如上面对应的应用名称就为 `sentinel-dashboard`|
| 参数 | 作用 |
| -------- | -------- |
| `-Dcsp.sentinel.dashboard.server=localhost:8080` | 向 Sentinel 接入端指定控制台的地址 |
| `-Dproject.name=sentinel-dashboard` | 向 Sentinel 指定应用名称,比如上面对应的应用名称就为 `sentinel-dashboard` |

全部的配置项可以参考 [启动配置项文档](https://github.com/alibaba/Sentinel/wiki/%E5%90%AF%E5%8A%A8%E9%85%8D%E7%BD%AE%E9%A1%B9)。

Expand Down
18 changes: 9 additions & 9 deletions sentinel-dashboard/Sentinel_Dashboard_Feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ Sentinel 提供了多种规则来保护系统的不同部分。流量控制规

> 通过环境变量进行配置时,因为不支持 `.` 所以需要将其更换为 `_`。

| 类型 | 默认值 | 最小值 | 描述
--- | --- | --- | --- | ---
sentinel.dashboard.auth.username | String | sentinel | 无 | 登录控制台的用户名,默认为 `sentinel`
sentinel.dashboard.auth.password | String | sentinel | 无 | 登录控制台的密码,默认为 `sentinel`
sentinel.dashboard.app.hideAppNoMachineMillis | Integer | 0 | 60000 | 是否隐藏无健康节点的应用,距离最近一次主机心跳时间的毫秒数,默认关闭
sentinel.dashboard.removeAppNoMachineMillis | Integer | 0 | 120000 | 是否自动删除无健康节点的应用,距离最近一次其下节点的心跳时间毫秒数,默认关闭
sentinel.dashboard.unhealthyMachineMillis | Integer | 60000 | 30000 | 主机失联判定,不可关闭
sentinel.dashboard.autoRemoveMachineMillis | Integer | 0 | 300000 | 距离最近心跳时间超过指定时间是否自动删除失联节点,默认关闭
|类型|默认值|最小值|描述
---|---|---|---|---
sentinel.dashboard.auth.username|String|sentinel|无|登录控制台的用户名,默认为 `sentinel`
sentinel.dashboard.auth.password|String|sentinel|无|登录控制台的密码,默认为 `sentinel`
sentinel.dashboard.app.hideAppNoMachineMillis|Integer|0|60000|是否隐藏无健康节点的应用,距离最近一次主机心跳时间的毫秒数,默认关闭
sentinel.dashboard.removeAppNoMachineMillis|Integer|0|120000|是否自动删除无健康节点的应用,距离最近一次其下节点的心跳时间毫秒数,默认关闭
sentinel.dashboard.unhealthyMachineMillis|Integer|60000|30000|主机失联判定,不可关闭
sentinel.dashboard.autoRemoveMachineMillis|Integer|0|300000|距离最近心跳时间超过指定时间是否自动删除失联节点,默认关闭

配置示例:

Expand All @@ -85,4 +85,4 @@ sentinel_dashboard_app_hideAppNoMachineMillis=60000
更多:

- [Sentinel 控制台启动和客户端接入](./README.md)
- [控制台 Wiki](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0)
- [控制台 Wiki](<https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0>)
8 changes: 4 additions & 4 deletions sentinel-demo/sentinel-demo-dubbo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ConsumerConfig consumerConfig() {

## Service Provider

Service Provider 用于向外界提供服务,处理各个消费者的调用请求。为了保护 Provider 不被激增的流量拖垮影响稳定性,可以给 Provider 配置 **QPS 模式**的限流,这样当每秒的请求量超过设定的阈值时会自动拒绝多的请求。限流粒度可以是服务接口和服务方法两种粒度。若希望整个服务接口的 QPS 不超过一定数值,则可以为对应服务接口资源(resourceName 为**接口全限定名**)配置 QPS 阈值;若希望服务的某个方法的 QPS 不超过一定数值,则可以为对应服务方法资源(resourceName 为**接口全限定名:方法签名**)配置 QPS 阈值。有关配置详情请参考 [流量控制 | Sentinel](https://github.com/alibaba/Sentinel/wiki/%E6%B5%81%E9%87%8F%E6%8E%A7%E5%88%B6)。
Service Provider 用于向外界提供服务,处理各个消费者的调用请求。为了保护 Provider 不被激增的流量拖垮影响稳定性,可以给 Provider 配置 **QPS 模式**的限流,这样当每秒的请求量超过设定的阈值时会自动拒绝多的请求。限流粒度可以是服务接口和服务方法两种粒度。若希望整个服务接口的 QPS 不超过一定数值,则可以为对应服务接口资源(resourceName 为**接口全限定名**)配置 QPS 阈值;若希望服务的某个方法的 QPS 不超过一定数值,则可以为对应服务方法资源(resourceName 为**接口全限定名:方法签名**)配置 QPS 阈值。有关配置详情请参考 [流量控制 | Sentinel](<https://github.com/alibaba/Sentinel/wiki/%E6%B5%81%E9%87%8F%E6%8E%A7%E5%88%B6>)。

Demo 1 演示了此限流场景,我们看一下这种模式的限流产生的效果。假设我们已经定义了某个服务接口 `com.alibaba.csp.sentinel.demo.dubbo.FooService`,其中有一个方法 `sayHello(java.lang.String)`,Provider 端该方法设定 QPS 阈值为 10。在 Consumer 端在 1s 之内连续发起 15 次调用,可以通过日志文件看到 Provider 端被限流。拦截日志统一记录在 `~/logs/csp/sentinel-block.log` 中:

Expand Down Expand Up @@ -70,7 +70,7 @@ Demo 2 演示了此限流场景,我们看一下这种模式的效果。假设

### 服务降级

当服务依赖于多个下游服务,而某个下游服务调用非常慢时,会严重影响当前服务的调用。这里我们可以利用 Sentinel 熔断降级的功能,为调用端配置基于平均 RT 的[降级规则](https://github.com/alibaba/Sentinel/wiki/%E7%86%94%E6%96%AD%E9%99%8D%E7%BA%A7)。这样当调用链路中某个服务调用的平均 RT 升高,在一定的次数内超过配置的 RT 阈值,Sentinel 就会对此调用资源进行降级操作,接下来的调用都会立刻拒绝,直到过了一段设定的时间后才恢复,从而保护服务不被调用端短板所影响。同时可以配合 fallback 功能使用,在被降级的时候提供相应的处理逻辑。
当服务依赖于多个下游服务,而某个下游服务调用非常慢时,会严重影响当前服务的调用。这里我们可以利用 Sentinel 熔断降级的功能,为调用端配置基于平均 RT 的[降级规则](<https://github.com/alibaba/Sentinel/wiki/%E7%86%94%E6%96%AD%E9%99%8D%E7%BA%A7>)。这样当调用链路中某个服务调用的平均 RT 升高,在一定的次数内超过配置的 RT 阈值,Sentinel 就会对此调用资源进行降级操作,接下来的调用都会立刻拒绝,直到过了一段设定的时间后才恢复,从而保护服务不被调用端短板所影响。同时可以配合 fallback 功能使用,在被降级的时候提供相应的处理逻辑。

## Fallback

Expand All @@ -80,11 +80,11 @@ Demo 2 的 Consumer 端提供了一个简单的 fallback 示例。

## Sentinel Dashboard

Sentinel 还提供 API 用于获取实时的监控信息,对应文档见[此处](https://github.com/alibaba/Sentinel/wiki/%E5%AE%9E%E6%97%B6%E7%9B%91%E6%8E%A7)。为了便于使用,Sentinel 还提供了一个控制台(Dashboard)用于配置规则、查看监控、机器发现等功能。
Sentinel 还提供 API 用于获取实时的监控信息,对应文档见[此处](<https://github.com/alibaba/Sentinel/wiki/%E5%AE%9E%E6%97%B6%E7%9B%91%E6%8E%A7>)。为了便于使用,Sentinel 还提供了一个控制台(Dashboard)用于配置规则、查看监控、机器发现等功能。

接入 Dashboard 的步骤(**缺一不可**):

1. 按照 [Sentinel 控制台文档](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0) 启动控制台
1. 按照 [Sentinel 控制台文档](<https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0>) 启动控制台
2. 应用引入 `sentinel-transport-simple-http` 依赖,以便控制台可以拉取对应应用的相关信息
3. 给应用添加相关的启动参数,启动应用。需要配置的参数有:
- `-Dcsp.sentinel.api.port`:客户端的 port,用于上报相关信息
Expand Down
12 changes: 6 additions & 6 deletions sentinel-extension/sentinel-parameter-flow-control/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sentinel Parameter Flow Control
# Sentinel Parameter Flow Control

This component provides functionality of flow control by frequent ("hot spot") parameters.

Expand Down Expand Up @@ -49,11 +49,11 @@ ParamFlowRuleManager.loadRules(Collections.singletonList(rule));
The description for fields of `ParamFlowRule`:

| Field | Description | Default |
| :----: | :----| :----|
| resource| resource name (**required**) ||
| count | flow control threshold (**required**) ||
| :---: | :--- | :--- |
| resource | resource name (**required**) | |
| count | flow control threshold (**required**) | |
| grade | metric type (QPS or thread count) | QPS mode |
| paramIdx | the index of provided parameter in `SphU.entry(xxx, args)` (**required**) ||
| paramFlowItemList | the exception items of parameter; you can set threshold to a specific parameter value ||
| paramIdx | the index of provided parameter in `SphU.entry(xxx, args)` (**required**) | |
| paramFlowItemList | the exception items of parameter; you can set threshold to a specific parameter value | |

Now the parameter flow control rules will take effect.
Loading