From e6660673921620df96f8ca1d0dde22b44be3cf90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=B0=A7?= Date: Tue, 25 Nov 2025 22:32:07 +0800 Subject: [PATCH 1/9] chore: remove node_modules from git & add to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7b944c74c8..0f365a7c06 100755 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ Thumbs.db # flattened pom file .flattened-pom.xml +node_modules/ From aa8f8d418ea13ea866b656b470982a2734e03db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=B0=A7?= Date: Tue, 25 Nov 2025 22:50:24 +0800 Subject: [PATCH 2/9] fix(docs): normalize README table style (MD060) across adapters and cluster modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赖尧 --- .../README.md | 10 +++---- .../sentinel-okhttp-adapter/README.md | 10 +++---- .../sentinel-spring-webmvc-adapter/README.md | 28 +++++++++---------- .../README.md | 28 +++++++++---------- .../README.md | 10 +++---- sentinel-dashboard/README.md | 8 +++--- .../sentinel-parameter-flow-control/README.md | 14 +++++----- 7 files changed, 54 insertions(+), 54 deletions(-) diff --git a/sentinel-adapter/sentinel-apache-httpclient-adapter/README.md b/sentinel-adapter/sentinel-apache-httpclient-adapter/README.md index 6bed9e8635..abee389f6e 100755 --- a/sentinel-adapter/sentinel-apache-httpclient-adapter/README.md +++ b/sentinel-adapter/sentinel-apache-httpclient-adapter/README.md @@ -32,11 +32,11 @@ 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) diff --git a/sentinel-adapter/sentinel-okhttp-adapter/README.md b/sentinel-adapter/sentinel-okhttp-adapter/README.md index e20e0a5185..aac5d90d70 100755 --- a/sentinel-adapter/sentinel-okhttp-adapter/README.md +++ b/sentinel-adapter/sentinel-okhttp-adapter/README.md @@ -26,11 +26,11 @@ 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 diff --git a/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md b/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md index f311f05004..59e90f814c 100755 --- a/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md +++ b/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md @@ -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` | diff --git a/sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/README.md b/sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/README.md index 79caf2638b..b45a2ca02c 100755 --- a/sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/README.md +++ b/sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/README.md @@ -85,23 +85,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` | diff --git a/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md b/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md index fb0522873e..0acfde911a 100644 --- a/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md +++ b/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md @@ -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 diff --git a/sentinel-dashboard/README.md b/sentinel-dashboard/README.md index 94c0ab27ac..22ed623838 100755 --- a/sentinel-dashboard/README.md +++ b/sentinel-dashboard/README.md @@ -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)。 diff --git a/sentinel-extension/sentinel-parameter-flow-control/README.md b/sentinel-extension/sentinel-parameter-flow-control/README.md index 4d7d1b14b4..7aa0be72bc 100644 --- a/sentinel-extension/sentinel-parameter-flow-control/README.md +++ b/sentinel-extension/sentinel-parameter-flow-control/README.md @@ -48,12 +48,12 @@ ParamFlowRuleManager.loadRules(Collections.singletonList(rule)); The description for fields of `ParamFlowRule`: -| Field | Description | Default | -| :----: | :----| :----| -| 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 || + | Field | Description | Default | + | :----: | :---- | :---- | + | 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 | | Now the parameter flow control rules will take effect. From f88bccd02a6da81590f766dfbf1a05bb8d7f9bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=B0=A7?= Date: Mon, 8 Dec 2025 18:05:01 +0800 Subject: [PATCH 3/9] docs: fix compact table style in parameter flow README --- .../sentinel-parameter-flow-control/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sentinel-extension/sentinel-parameter-flow-control/README.md b/sentinel-extension/sentinel-parameter-flow-control/README.md index 4d7d1b14b4..d28157c4ce 100644 --- a/sentinel-extension/sentinel-parameter-flow-control/README.md +++ b/sentinel-extension/sentinel-parameter-flow-control/README.md @@ -48,12 +48,12 @@ ParamFlowRuleManager.loadRules(Collections.singletonList(rule)); The description for fields of `ParamFlowRule`: -| Field | Description | Default | -| :----: | :----| :----| -| 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 || +|Field|Description|Default| +|:---:|:---|:---| +|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| | Now the parameter flow control rules will take effect. From 7b9f7c78bdfe1a23c39140ef25fc85762a404626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=B0=A7?= Date: Mon, 8 Dec 2025 23:26:02 +0800 Subject: [PATCH 4/9] docs: fix markdownlint MD009 and MD060 in README files --- README.md | 40 ++++----- .../README.md | 8 +- .../sentinel-okhttp-adapter/README.md | 8 +- .../sentinel-spring-webmvc-adapter/README.md | 23 +---- .../README.md | 8 +- sentinel-dashboard/README.md | 61 +++++++------ .../Sentinel_Dashboard_Feature.md | 86 +++++++++---------- sentinel-demo/sentinel-demo-dubbo/README.md | 72 ++++++++-------- .../sentinel-parameter-flow-control/README.md | 10 +-- 9 files changed, 138 insertions(+), 178 deletions(-) diff --git a/README.md b/README.md index ac11e1ab63..3e76d41459 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Sentinel: The Sentinel of Your Microservices +# Sentinel: The Sentinel of Your Microservices Sentinel Logo @@ -18,7 +18,7 @@ to guarantee reliability and resilience for microservices. Sentinel has the following features: -- **Rich applicable scenarios**: Sentinel has been wildly used in Alibaba, and has covered almost all the core-scenarios in Double-11 (11.11) Shopping Festivals in the past 10 years, such as “Second Kill” which needs to limit burst flow traffic to meet the system capacity, message peak clipping and valley fills, circuit breaking for unreliable downstream services, cluster flow control, etc. +- **Rich applicable scenarios**: Sentinel has been wildly used in Alibaba, and has covered almost all the core-scenarios in Double-11 (11.11) Shopping Festivals in the past 10 years, such as 鈥淪econd Kill鈥?which needs to limit burst flow traffic to meet the system capacity, message peak clipping and valley fills, circuit breaking for unreliable downstream services, cluster flow control, etc. - **Real-time monitoring**: Sentinel also provides real-time monitoring ability. You can see the runtime information of a single machine in real-time, and the aggregated runtime info of a cluster with less than 500 nodes. - **Widespread open-source ecosystem**: Sentinel provides out-of-box integrations with commonly-used frameworks and libraries such as Spring Cloud, gRPC, Apache Dubbo and Quarkus. You can easily use Sentinel by simply add the adapter dependency to your services. - **Polyglot support**: Sentinel has provided native support for Java, [Go](https://github.com/alibaba/sentinel-golang), [C++](https://github.com/alibaba/sentinel-cpp) and [Rust](https://github.com/sentinel-group/sentinel-rust). @@ -35,7 +35,7 @@ Please refer to [OpenSergo](https://opensergo.io/) for details. See the [Sentinel Website](https://sentinelguard.io/) for the official website of Sentinel. -See the [中文文档](https://sentinelguard.io/zh-cn/docs/introduction.html) for document in Chinese. +See the [涓枃鏂囨。](https://sentinelguard.io/zh-cn/docs/introduction.html) for document in Chinese. See the [Wiki](https://github.com/alibaba/Sentinel/wiki) for full documentation, examples, blog posts, operational details and other information. @@ -112,13 +112,13 @@ For more information, please refer to [How To Use](https://sentinelguard.io/en-u After running the demo for a while, you can see the following records in `~/logs/csp/${appName}-metrics.log.{date}` (When using the default `DateFileLogHandler`). ```plaintext -|--timestamp-|------date time----|-resource-|p |block|s |e|rt |occupied -1529998904000|2018-06-26 15:41:44|HelloWorld|20|0 |20|0|0 |0 -1529998905000|2018-06-26 15:41:45|HelloWorld|20|5579 |20|0|728 |0 -1529998906000|2018-06-26 15:41:46|HelloWorld|20|15698|20|0|0 |0 -1529998907000|2018-06-26 15:41:47|HelloWorld|20|19262|20|0|0 |0 -1529998908000|2018-06-26 15:41:48|HelloWorld|20|19502|20|0|0 |0 -1529998909000|2018-06-26 15:41:49|HelloWorld|20|18386|20|0|0 |0 +|--timestamp-|------date time----|-resource-|p|block|s|e|rt|occupied +1529998904000|2018-06-26 15:41:44|HelloWorld|20|0|20|0|0|0 +1529998905000|2018-06-26 15:41:45|HelloWorld|20|5579|20|0|728|0 +1529998906000|2018-06-26 15:41:46|HelloWorld|20|15698|20|0|0|0 +1529998907000|2018-06-26 15:41:47|HelloWorld|20|19262|20|0|0|0 +1529998908000|2018-06-26 15:41:48|HelloWorld|20|19502|20|0|0|0 +1529998909000|2018-06-26 15:41:49|HelloWorld|20|18386|20|0|0|0 p stands for incoming request, block for blocked by rules, s for success handled by Sentinel, e for exception count, rt for average response time (ms), occupied stands for occupiedPassQps since 1.5.0 which enable us booking more than 1 shot when entering. ``` @@ -160,9 +160,9 @@ You can start with the issues labeled with [`good first issue`](https://github.c ## Enterprise Service -If you need Sentinel enterprise service support (Sentinel 企业版), or purchase cloud product services, +If you need Sentinel enterprise service support (Sentinel 浼佷笟鐗?, or purchase cloud product services, you can join the discussion by the DingTalk group (34754806). It can also be directly activated -and used through the [microservice engine (MSE 微服务引擎) provided by Alibaba Cloud](https://cn.aliyun.com/product/aliware/mse?spm=sentinel-github.index.0.0.0). +and used through the [microservice engine (MSE 寰湇鍔″紩鎿? provided by Alibaba Cloud](https://cn.aliyun.com/product/aliware/mse?spm=sentinel-github.index.0.0.0). ## Credits @@ -178,13 +178,13 @@ If you are using Sentinel, please [add your company here](https://github.com/ali ![Alibaba Group](https://docs.alibabagroup.com/assets2/images/en/global/logo_header.png) ![AntFin](https://user-images.githubusercontent.com/9434884/90598732-30961c00-e226-11ea-8c86-0b1d7f7875c7.png) ![Taiping Renshou](http://www.cntaiping.com/tplresource/cms/www/taiping/img/home_new/tp_logo_img.png) -![拼多多](http://cdn.pinduoduo.com/assets/img/pdd_logo_v3.png) -![爱奇艺](https://user-images.githubusercontent.com/9434884/90598445-a51c8b00-e225-11ea-9327-3543525f3f2a.png) +![鎷煎澶歖(http://cdn.pinduoduo.com/assets/img/pdd_logo_v3.png) +![鐖卞鑹篯(https://user-images.githubusercontent.com/9434884/90598445-a51c8b00-e225-11ea-9327-3543525f3f2a.png) ![Shunfeng Technology](https://user-images.githubusercontent.com/9434884/48463502-2f48eb80-e817-11e8-984f-2f9b1b789e2d.png) -![二维火](https://user-images.githubusercontent.com/9434884/49358468-bc43de00-f70d-11e8-97fe-0bf05865f29f.png) +![浜岀淮鐏玗(https://user-images.githubusercontent.com/9434884/49358468-bc43de00-f70d-11e8-97fe-0bf05865f29f.png) ![Mandao](https://user-images.githubusercontent.com/9434884/48463559-6cad7900-e817-11e8-87e4-42952b074837.png) -![文轩在线](http://static.winxuancdn.com/css/v2/images/logo.png) -![客如云](https://www.keruyun.com/static/krynew/images/logo.png) -![亲宝宝](https://stlib.qbb6.com/wclt/img/home_hd/version1/title_logo.png) -![金汇金融](https://res.jinhui365.com/r/images/logo2.png?v=1.527) -![闪电购](http://cdn.52shangou.com/shandianbang/official-source/3.1.1/build/images/logo.png) +![鏂囪僵鍦ㄧ嚎](http://static.winxuancdn.com/css/v2/images/logo.png) +![瀹㈠浜慮(https://www.keruyun.com/static/krynew/images/logo.png) +![浜插疂瀹漖(https://stlib.qbb6.com/wclt/img/home_hd/version1/title_logo.png) +![閲戞眹閲戣瀺](https://res.jinhui365.com/r/images/logo2.png?v=1.527) +![闂數璐璢(http://cdn.52shangou.com/shandianbang/official-source/3.1.1/build/images/logo.png) diff --git a/sentinel-adapter/sentinel-apache-httpclient-adapter/README.md b/sentinel-adapter/sentinel-apache-httpclient-adapter/README.md index abee389f6e..54c0e2b1fc 100755 --- a/sentinel-adapter/sentinel-apache-httpclient-adapter/README.md +++ b/sentinel-adapter/sentinel-apache-httpclient-adapter/README.md @@ -1,4 +1,4 @@ -# Sentinel Apache Httpclient Adapter +# Sentinel Apache Httpclient Adapter ## Introduction @@ -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) diff --git a/sentinel-adapter/sentinel-okhttp-adapter/README.md b/sentinel-adapter/sentinel-okhttp-adapter/README.md index aac5d90d70..c900a62eac 100755 --- a/sentinel-adapter/sentinel-okhttp-adapter/README.md +++ b/sentinel-adapter/sentinel-okhttp-adapter/README.md @@ -1,4 +1,4 @@ -# Sentinel OkHttp Adapter +# Sentinel OkHttp Adapter ## Introduction @@ -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 diff --git a/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md b/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md index 59e90f814c..a8f87c5072 100755 --- a/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md +++ b/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md @@ -1,4 +1,4 @@ -# Sentinel Spring MVC Adapter +# Sentinel Spring MVC Adapter ## Introduction @@ -91,23 +91,4 @@ 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` | - | - -- `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` | - -- `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||------|------------|------|-------||`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`|- `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`| diff --git a/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md b/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md index 0acfde911a..1dd0940187 100644 --- a/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md +++ b/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md @@ -1,4 +1,4 @@ -# Sentinel Token Server (Envoy RLS implementation) +# Sentinel Token Server (Envoy RLS implementation) This module provides the [Envoy rate limiting gRPC service](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/other_features/global_rate_limiting#arch-overview-rate-limit) implementation with Sentinel token server. @@ -50,11 +50,7 @@ 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 diff --git a/sentinel-dashboard/README.md b/sentinel-dashboard/README.md index 22ed623838..51a3650cbc 100755 --- a/sentinel-dashboard/README.md +++ b/sentinel-dashboard/README.md @@ -1,22 +1,22 @@ -# Sentinel 控制台 +# Sentinel 鎺у埗鍙? -## 0. 概述 +## 0. 姒傝堪 -Sentinel 控制台是流量控制、熔断降级规则统一配置和管理的入口,它为用户提供了机器自发现、簇点链路自发现、监控、规则配置等功能。在 Sentinel 控制台上,我们可以配置规则并实时查看流量控制效果。 +Sentinel 鎺у埗鍙版槸娴侀噺鎺у埗銆佺啍鏂檷绾ц鍒欑粺涓€閰嶇疆鍜岀鐞嗙殑鍏ュ彛锛屽畠涓虹敤鎴锋彁渚涗簡鏈哄櫒鑷彂鐜般€佺皣鐐归摼璺嚜鍙戠幇銆佺洃鎺с€佽鍒欓厤缃瓑鍔熻兘銆傚湪 Sentinel 鎺у埗鍙颁笂锛屾垜浠彲浠ラ厤缃鍒欏苟瀹炴椂鏌ョ湅娴侀噺鎺у埗鏁堟灉銆? -## 1. 编译和启动 +## 1. 缂栬瘧鍜屽惎鍔? -### 1.1 如何编译 +### 1.1 濡備綍缂栬瘧 -使用如下命令将代码打包成一个 fat jar: +浣跨敤濡備笅鍛戒护灏嗕唬鐮佹墦鍖呮垚涓€涓?fat jar: ```bash mvn clean package ``` -### 1.2 如何启动 +### 1.2 濡備綍鍚姩 -使用如下命令启动编译后的控制台: +浣跨敤濡備笅鍛戒护鍚姩缂栬瘧鍚庣殑鎺у埗鍙帮細 ```bash java -Dserver.port=8080 \ @@ -25,45 +25,42 @@ java -Dserver.port=8080 \ -jar target/sentinel-dashboard.jar ``` -上述命令中我们指定几个 JVM 参数,其中 `-Dserver.port=8080` 是 Spring Boot 的参数, -用于指定 Spring Boot 服务端启动端口为 `8080`。其余几个是 Sentinel 客户端的参数。 +涓婅堪鍛戒护涓垜浠寚瀹氬嚑涓?JVM 鍙傛暟锛屽叾涓?`-Dserver.port=8080` 鏄?Spring Boot 鐨勫弬鏁帮紝 +鐢ㄤ簬鎸囧畾 Spring Boot 鏈嶅姟绔惎鍔ㄧ鍙d负 `8080`銆傚叾浣欏嚑涓槸 Sentinel 瀹㈡埛绔殑鍙傛暟銆? -为便于演示,我们对控制台本身加入了流量控制功能,具体做法是引入 Sentinel 提供的 `CommonFilter` 这个 Servlet Filter。 -上述 JVM 参数的含义是: +涓轰究浜庢紨绀猴紝鎴戜滑瀵规帶鍒跺彴鏈韩鍔犲叆浜嗘祦閲忔帶鍒跺姛鑳斤紝鍏蜂綋鍋氭硶鏄紩鍏?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)。 +鍏ㄩ儴鐨勯厤缃」鍙互鍙傝€?[鍚姩閰嶇疆椤规枃妗(https://github.com/alibaba/Sentinel/wiki/%E5%90%AF%E5%8A%A8%E9%85%8D%E7%BD%AE%E9%A1%B9)銆? -经过上述配置,控制台启动后会自动向自己发送心跳。程序启动后浏览器访问 `localhost:8080` 即可访问 Sentinel 控制台。 +缁忚繃涓婅堪閰嶇疆锛屾帶鍒跺彴鍚姩鍚庝細鑷姩鍚戣嚜宸卞彂閫佸績璺炽€傜▼搴忓惎鍔ㄥ悗娴忚鍣ㄨ闂?`localhost:8080` 鍗冲彲璁块棶 Sentinel 鎺у埗鍙般€? -从 Sentinel 1.6.0 开始,Sentinel 控制台支持简单的**登录**功能,默认用户名和密码都是 `sentinel`。用户可以通过如下参数进行配置: +浠?Sentinel 1.6.0 寮€濮嬶紝Sentinel 鎺у埗鍙版敮鎸佺畝鍗曠殑**鐧诲綍**鍔熻兘锛岄粯璁ょ敤鎴峰悕鍜屽瘑鐮侀兘鏄?`sentinel`銆傜敤鎴峰彲浠ラ€氳繃濡備笅鍙傛暟杩涜閰嶇疆锛? -- `-Dsentinel.dashboard.auth.username=sentinel` 用于指定控制台的登录用户名为 `sentinel`; -- `-Dsentinel.dashboard.auth.password=123456` 用于指定控制台的登录密码为 `123456`;如果省略这两个参数,默认用户和密码均为 `sentinel`; -- `-Dserver.servlet.session.timeout=7200` 用于指定 Spring Boot 服务端 session 的过期时间,如 `7200` 表示 7200 秒;`60m` 表示 60 分钟,默认为 30 分钟; +- `-Dsentinel.dashboard.auth.username=sentinel` 鐢ㄤ簬鎸囧畾鎺у埗鍙扮殑鐧诲綍鐢ㄦ埛鍚嶄负 `sentinel`锛? +- `-Dsentinel.dashboard.auth.password=123456` 鐢ㄤ簬鎸囧畾鎺у埗鍙扮殑鐧诲綍瀵嗙爜涓?`123456`锛涘鏋滅渷鐣ヨ繖涓や釜鍙傛暟锛岄粯璁ょ敤鎴峰拰瀵嗙爜鍧囦负 `sentinel`锛? +- `-Dserver.servlet.session.timeout=7200` 鐢ㄤ簬鎸囧畾 Spring Boot 鏈嶅姟绔?session 鐨勮繃鏈熸椂闂达紝濡?`7200` 琛ㄧず 7200 绉掞紱`60m` 琛ㄧず 60 鍒嗛挓锛岄粯璁や负 30 鍒嗛挓锛? -## 2. 客户端接入 +## 2. 瀹㈡埛绔帴鍏? -选择合适的方式接入 Sentinel,然后在应用启动时加入 JVM 参数 `-Dcsp.sentinel.dashboard.server=consoleIp:port` 指定控制台地址和端口。 -确保客户端有访问量,**Sentinel 会在客户端首次调用的时候进行初始化,开始向控制台发送心跳包**,将客户端纳入到控制台的管辖之下。 +閫夋嫨鍚堥€傜殑鏂瑰紡鎺ュ叆 Sentinel锛岀劧鍚庡湪搴旂敤鍚姩鏃跺姞鍏?JVM 鍙傛暟 `-Dcsp.sentinel.dashboard.server=consoleIp:port` 鎸囧畾鎺у埗鍙板湴鍧€鍜岀鍙c€? +纭繚瀹㈡埛绔湁璁块棶閲忥紝**Sentinel 浼氬湪瀹㈡埛绔娆¤皟鐢ㄧ殑鏃跺€欒繘琛屽垵濮嬪寲锛屽紑濮嬪悜鎺у埗鍙板彂閫佸績璺冲寘**锛屽皢瀹㈡埛绔撼鍏ュ埌鎺у埗鍙扮殑绠¤緰涔嬩笅銆? -客户端接入的详细步骤请参考 [Wiki 文档](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0#3-%E5%AE%A2%E6%88%B7%E7%AB%AF%E6%8E%A5%E5%85%A5%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#3-%E5%AE%A2%E6%88%B7%E7%AB%AF%E6%8E%A5%E5%85%A5%E6%8E%A7%E5%88%B6%E5%8F%B0)銆? -## 3. 验证是否接入成功 +## 3. 楠岃瘉鏄惁鎺ュ叆鎴愬姛 -客户端正确配置并启动后,会**在初次调用后**主动向控制台发送心跳包,汇报自己的存在; -控制台收到客户端心跳包之后,会在左侧导航栏中显示该客户端信息。如果控制台能够看到客户端的机器信息,则表明客户端接入成功了。 +瀹㈡埛绔纭厤缃苟鍚姩鍚庯紝浼?*鍦ㄥ垵娆¤皟鐢ㄥ悗**涓诲姩鍚戞帶鍒跺彴鍙戦€佸績璺冲寘锛屾眹鎶ヨ嚜宸辩殑瀛樺湪锛? +鎺у埗鍙版敹鍒板鎴风蹇冭烦鍖呬箣鍚庯紝浼氬湪宸︿晶瀵艰埅鏍忎腑鏄剧ず璇ュ鎴风淇℃伅銆傚鏋滄帶鍒跺彴鑳藉鐪嬪埌瀹㈡埛绔殑鏈哄櫒淇℃伅锛屽垯琛ㄦ槑瀹㈡埛绔帴鍏ユ垚鍔熶簡銆? -## 6. 构建Docker镜像 +## 6. 鏋勫缓Docker闀滃儚 ```bash docker build --build-arg SENTINEL_VERSION=1.8.9 -t ${REGISTRY}/sentinel-dashboard:v1.8.9 . ``` -*注意:Sentinel 控制台目前仅支持单机部署。Sentinel 控制台项目提供 Sentinel 功能全集示例,不作为开箱即用的生产环境控制台,不提供安全可靠保障。若希望在生产环境使用请根据[文档](https://github.com/alibaba/Sentinel/wiki/%E5%9C%A8%E7%94%9F%E4%BA%A7%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%BD%BF%E7%94%A8-Sentinel)自行进行定制和改造。* +*娉ㄦ剰锛歋entinel 鎺у埗鍙扮洰鍓嶄粎鏀寔鍗曟満閮ㄧ讲銆係entinel 鎺у埗鍙伴」鐩彁渚?Sentinel 鍔熻兘鍏ㄩ泦绀轰緥锛屼笉浣滀负寮€绠卞嵆鐢ㄧ殑鐢熶骇鐜鎺у埗鍙帮紝涓嶆彁渚涘畨鍏ㄥ彲闈犱繚闅溿€傝嫢甯屾湜鍦ㄧ敓浜х幆澧冧娇鐢ㄨ鏍规嵁[鏂囨。](https://github.com/alibaba/Sentinel/wiki/%E5%9C%A8%E7%94%9F%E4%BA%A7%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%BD%BF%E7%94%A8-Sentinel)鑷杩涜瀹氬埗鍜屾敼閫犮€? -更多:[控制台功能介绍](./Sentinel_Dashboard_Feature.md)。 +鏇村锛歔鎺у埗鍙板姛鑳戒粙缁峕(./Sentinel_Dashboard_Feature.md)銆? diff --git a/sentinel-dashboard/Sentinel_Dashboard_Feature.md b/sentinel-dashboard/Sentinel_Dashboard_Feature.md index 381f304a2d..50ad6d92d1 100755 --- a/sentinel-dashboard/Sentinel_Dashboard_Feature.md +++ b/sentinel-dashboard/Sentinel_Dashboard_Feature.md @@ -1,88 +1,88 @@ -# Sentinel 控制台功能介绍 +# Sentinel 鎺у埗鍙板姛鑳戒粙缁? -## 0. 概述 +## 0. 姒傝堪 -Sentinel 控制台是流量控制、熔断降级规则统一配置和管理的入口,它为用户提供了机器自发现、簇点链路自发现、监控、规则配置等功能。在 Sentinel 控制台上,我们可以配置规则并实时查看流量控制效果。使用 Sentinel 控制台的流程如下: +Sentinel 鎺у埗鍙版槸娴侀噺鎺у埗銆佺啍鏂檷绾ц鍒欑粺涓€閰嶇疆鍜岀鐞嗙殑鍏ュ彛锛屽畠涓虹敤鎴锋彁渚涗簡鏈哄櫒鑷彂鐜般€佺皣鐐归摼璺嚜鍙戠幇銆佺洃鎺с€佽鍒欓厤缃瓑鍔熻兘銆傚湪 Sentinel 鎺у埗鍙颁笂锛屾垜浠彲浠ラ厤缃鍒欏苟瀹炴椂鏌ョ湅娴侀噺鎺у埗鏁堟灉銆備娇鐢?Sentinel 鎺у埗鍙扮殑娴佺▼濡備笅锛? ```plaintext -客户端接入 -> 机器自发现 -> 查看簇点链路 -> 配置流控规则 -> 查看流控效果 +瀹㈡埛绔帴鍏?-> 鏈哄櫒鑷彂鐜?-> 鏌ョ湅绨囩偣閾捐矾 -> 閰嶇疆娴佹帶瑙勫垯 -> 鏌ョ湅娴佹帶鏁堟灉 ``` -## 1. 功能介绍 +## 1. 鍔熻兘浠嬬粛 -### 1.1 机器自发现 +### 1.1 鏈哄櫒鑷彂鐜? -Sentinel 提供内置的机器自发现功能,无需依赖第三方服务发现组件即可实现客户端的发现。点击 Sentinel 控制台左侧导航栏的“机器列表”菜单,可查看集群机器数量和机器健康状况。 +Sentinel 鎻愪緵鍐呯疆鐨勬満鍣ㄨ嚜鍙戠幇鍔熻兘锛屾棤闇€渚濊禆绗笁鏂规湇鍔″彂鐜扮粍浠跺嵆鍙疄鐜板鎴风鐨勫彂鐜般€傜偣鍑?Sentinel 鎺у埗鍙板乏渚у鑸爮鐨勨€滄満鍣ㄥ垪琛ㄢ€濊彍鍗曪紝鍙煡鐪嬮泦缇ゆ満鍣ㄦ暟閲忓拰鏈哄櫒鍋ュ悍鐘跺喌銆? -### 1.2 簇点链路自发现 +### 1.2 绨囩偣閾捐矾鑷彂鐜? -Sentinel 将每一个需要流控的 URL 或者接口称为一个资源,并使用URL地址或方法签名表示资源。Sentinel 会自动发现所有潜在的资源和资源之间的调用链,并在“簇点链路”页面展示。 -资源是设置流控规则的载体,通过簇点链路自发现,可以方便的对重要资源设置流控规则、熔断降级规则等。 +Sentinel 灏嗘瘡涓€涓渶瑕佹祦鎺х殑 URL 鎴栬€呮帴鍙gО涓轰竴涓祫婧愶紝骞朵娇鐢║RL鍦板潃鎴栨柟娉曠鍚嶈〃绀鸿祫婧愩€係entinel 浼氳嚜鍔ㄥ彂鐜版墍鏈夋綔鍦ㄧ殑璧勬簮鍜岃祫婧愪箣闂寸殑璋冪敤閾撅紝骞跺湪鈥滅皣鐐归摼璺€濋〉闈㈠睍绀恒€? +璧勬簮鏄缃祦鎺ц鍒欑殑杞戒綋锛岄€氳繃绨囩偣閾捐矾鑷彂鐜帮紝鍙互鏂逛究鐨勫閲嶈璧勬簮璁剧疆娴佹帶瑙勫垯銆佺啍鏂檷绾ц鍒欑瓑銆? -> 注意:**客户端有访问量之后,才能在簇点链路页面看到资源监控(lazy-initializing)**。 +> 娉ㄦ剰锛?*瀹㈡埛绔湁璁块棶閲忎箣鍚庯紝鎵嶈兘鍦ㄧ皣鐐归摼璺〉闈㈢湅鍒拌祫婧愮洃鎺э紙lazy-initializing锛?*銆? -### 1.3 实时监控 +### 1.3 瀹炴椂鐩戞帶 -Sentinel 监控功能能够实时查看集群中每个资源的实时访问以及流控情况。控制台左侧导航栏的“实时监控”菜单对应该功能。 +Sentinel 鐩戞帶鍔熻兘鑳藉瀹炴椂鏌ョ湅闆嗙兢涓瘡涓祫婧愮殑瀹炴椂璁块棶浠ュ強娴佹帶鎯呭喌銆傛帶鍒跺彴宸︿晶瀵艰埅鏍忕殑鈥滃疄鏃剁洃鎺р€濊彍鍗曞搴旇鍔熻兘銆? -### 1.4 流控降级规则设置 +### 1.4 娴佹帶闄嶇骇瑙勫垯璁剧疆 -Sentinel 提供了多种规则来保护系统的不同部分。流量控制规则用于保护服务提供方,熔断降级规则用于保护服务消费方,系统保护规则用于保护整个系统。 +Sentinel 鎻愪緵浜嗗绉嶈鍒欐潵淇濇姢绯荤粺鐨勪笉鍚岄儴鍒嗐€傛祦閲忔帶鍒惰鍒欑敤浜庝繚鎶ゆ湇鍔℃彁渚涙柟锛岀啍鏂檷绾ц鍒欑敤浜庝繚鎶ゆ湇鍔℃秷璐规柟锛岀郴缁熶繚鎶よ鍒欑敤浜庝繚鎶ゆ暣涓郴缁熴€? -#### 1.4.1 流量控制规则 +#### 1.4.1 娴侀噺鎺у埗瑙勫垯 -流量控制规则用于保护服务提供方,服务提供方指任何可以对外提供服务的系统,比如向终端用户提供 Web 服务的 Web 应用,向微服务消费方提供服务的 Dubbo Service Provider 等。 -系统的服务能力是有限的,如果消费方请求速度过高,则采用相应的保护策略,或是直接拒绝,或是排队等待。通过“流控规则”页面可以查看和配置流量控制规则。 +娴侀噺鎺у埗瑙勫垯鐢ㄤ簬淇濇姢鏈嶅姟鎻愪緵鏂癸紝鏈嶅姟鎻愪緵鏂规寚浠讳綍鍙互瀵瑰鎻愪緵鏈嶅姟鐨勭郴缁燂紝姣斿鍚戠粓绔敤鎴锋彁渚?Web 鏈嶅姟鐨?Web 搴旂敤锛屽悜寰湇鍔℃秷璐规柟鎻愪緵鏈嶅姟鐨?Dubbo Service Provider 绛夈€? +绯荤粺鐨勬湇鍔¤兘鍔涙槸鏈夐檺鐨勶紝濡傛灉娑堣垂鏂硅姹傞€熷害杩囬珮锛屽垯閲囩敤鐩稿簲鐨勪繚鎶ょ瓥鐣ワ紝鎴栨槸鐩存帴鎷掔粷锛屾垨鏄帓闃熺瓑寰呫€傞€氳繃鈥滄祦鎺ц鍒欌€濋〉闈㈠彲浠ユ煡鐪嬪拰閰嶇疆娴侀噺鎺у埗瑙勫垯銆? -#### 1.4.2 熔断降级规则 +#### 1.4.2 鐔旀柇闄嶇骇瑙勫垯 -降级规则用于保护服务消费方。在微服务架构中,业务系统通常要依赖多个服务,依赖的某个服务不可用将会影响业务系统的可用性。解决这个问题的方法是及时发现服务的“不可用”状态,在调用时快速失败而不是等待调动超时或者重试。Sentinel 通过熔断降级来达到快速失败的目的。通过“降级规则”页面可以查看和配置降级规则。 +闄嶇骇瑙勫垯鐢ㄤ簬淇濇姢鏈嶅姟娑堣垂鏂广€傚湪寰湇鍔℃灦鏋勪腑锛屼笟鍔$郴缁熼€氬父瑕佷緷璧栧涓湇鍔★紝渚濊禆鐨勬煇涓湇鍔′笉鍙敤灏嗕細褰卞搷涓氬姟绯荤粺鐨勫彲鐢ㄦ€с€傝В鍐宠繖涓棶棰樼殑鏂规硶鏄強鏃跺彂鐜版湇鍔$殑鈥滀笉鍙敤鈥濈姸鎬侊紝鍦ㄨ皟鐢ㄦ椂蹇€熷け璐ヨ€屼笉鏄瓑寰呰皟鍔ㄨ秴鏃舵垨鑰呴噸璇曘€係entinel 閫氳繃鐔旀柇闄嶇骇鏉ヨ揪鍒板揩閫熷け璐ョ殑鐩殑銆傞€氳繃鈥滈檷绾ц鍒欌€濋〉闈㈠彲浠ユ煡鐪嬪拰閰嶇疆闄嶇骇瑙勫垯銆? -#### 1.4.3 系统保护规则 +#### 1.4.3 绯荤粺淇濇姢瑙勫垯 -系统保护规则(简称`系统规则`)用于保护整个系统指标处于安全水位。无论是服务提供方还是消费方,活跃线程数过多、系统LOAD等过高都是系统处于高水位的指标。当系统水位过高时,系统应拒绝对外提供服务以便迅速降低资源占用。通过“系统规则”页面可以查看和设置系统保护规则。 +绯荤粺淇濇姢瑙勫垯锛堢畝绉癭绯荤粺瑙勫垯`锛夌敤浜庝繚鎶ゆ暣涓郴缁熸寚鏍囧浜庡畨鍏ㄦ按浣嶃€傛棤璁烘槸鏈嶅姟鎻愪緵鏂硅繕鏄秷璐规柟锛屾椿璺冪嚎绋嬫暟杩囧銆佺郴缁烲OAD绛夎繃楂橀兘鏄郴缁熷浜庨珮姘翠綅鐨勬寚鏍囥€傚綋绯荤粺姘翠綅杩囬珮鏃讹紝绯荤粺搴旀嫆缁濆澶栨彁渚涙湇鍔′互渚胯繀閫熼檷浣庤祫婧愬崰鐢ㄣ€傞€氳繃鈥滅郴缁熻鍒欌€濋〉闈㈠彲浠ユ煡鐪嬪拰璁剧疆绯荤粺淇濇姢瑙勫垯銆? -## 2. 限制 +## 2. 闄愬埗 -本控制台只是用于演示 Sentinel 的基本能力和工作流程,并没有依赖生产环境中所必需的组件,比如**持久化的后端数据库、可靠的配置中心**等。 -目前 Sentinel 采用内存态的方式存储监控和规则数据,监控最长存储时间为 5 分钟,控制台重启后数据丢失。 +鏈帶鍒跺彴鍙槸鐢ㄤ簬婕旂ず Sentinel 鐨勫熀鏈兘鍔涘拰宸ヤ綔娴佺▼锛屽苟娌℃湁渚濊禆鐢熶骇鐜涓墍蹇呴渶鐨勭粍浠讹紝姣斿**鎸佷箙鍖栫殑鍚庣鏁版嵁搴撱€佸彲闈犵殑閰嶇疆涓績**绛夈€? +鐩墠 Sentinel 閲囩敤鍐呭瓨鎬佺殑鏂瑰紡瀛樺偍鐩戞帶鍜岃鍒欐暟鎹紝鐩戞帶鏈€闀垮瓨鍌ㄦ椂闂翠负 5 鍒嗛挓锛屾帶鍒跺彴閲嶅惎鍚庢暟鎹涪澶便€? -## 3. 配置项 +## 3. 閰嶇疆椤? -控制台的一些特性可以通过配置项来进行配置,配置项主要有两个来源:`System.getProperty()` 和 `System.getenv()`,同时存在时后者可以覆盖前者。 +鎺у埗鍙扮殑涓€浜涚壒鎬у彲浠ラ€氳繃閰嶇疆椤规潵杩涜閰嶇疆锛岄厤缃」涓昏鏈変袱涓潵婧愶細`System.getProperty()` 鍜?`System.getenv()`锛屽悓鏃跺瓨鍦ㄦ椂鍚庤€呭彲浠ヨ鐩栧墠鑰呫€? -> 通过环境变量进行配置时,因为不支持 `.` 所以需要将其更换为 `_`。 +> 閫氳繃鐜鍙橀噺杩涜閰嶇疆鏃讹紝鍥犱负涓嶆敮鎸?`.` 鎵€浠ラ渶瑕佸皢鍏舵洿鎹负 `_`銆? -项 | 类型 | 默认值 | 最小值 | 描述 ---- | --- | --- | --- | --- -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| 璺濈鏈€杩戝績璺虫椂闂磋秴杩囨寚瀹氭椂闂存槸鍚﹁嚜鍔ㄥ垹闄ゅけ鑱旇妭鐐癸紝榛樿鍏抽棴 -配置示例: +閰嶇疆绀轰緥锛? -- 命令行方式: +- 鍛戒护琛屾柟寮忥細 ```shell java -Dsentinel.dashboard.app.hideAppNoMachineMillis=60000 ``` -- Java 方式: +- Java 鏂瑰紡锛? ```java System.setProperty("sentinel.dashboard.app.hideAppNoMachineMillis", "60000"); ``` -- 环境变量方式: +- 鐜鍙橀噺鏂瑰紡锛? ```shell sentinel_dashboard_app_hideAppNoMachineMillis=60000 ``` -更多: +鏇村锛? -- [Sentinel 控制台启动和客户端接入](./README.md) -- [控制台 Wiki](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0) +- [Sentinel 鎺у埗鍙板惎鍔ㄥ拰瀹㈡埛绔帴鍏(./README.md) +- [鎺у埗鍙?Wiki](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0) diff --git a/sentinel-demo/sentinel-demo-dubbo/README.md b/sentinel-demo/sentinel-demo-dubbo/README.md index 84ab3a5796..29e7f71770 100644 --- a/sentinel-demo/sentinel-demo-dubbo/README.md +++ b/sentinel-demo/sentinel-demo-dubbo/README.md @@ -1,6 +1,6 @@ -# Sentinel Dubbo Demo +# Sentinel Dubbo Demo -Sentinel 提供了与 Dubbo 整合的模块 - Sentinel Dubbo Adapter,主要包括针对 Service Provider 和 Service Consumer 实现的 Filter。使用时用户只需引入以下模块(以 Maven 为例): +Sentinel 鎻愪緵浜嗕笌 Dubbo 鏁村悎鐨勬ā鍧?- Sentinel Dubbo Adapter锛屼富瑕佸寘鎷拡瀵?Service Provider 鍜?Service Consumer 瀹炵幇鐨?Filter銆備娇鐢ㄦ椂鐢ㄦ埛鍙渶寮曞叆浠ヤ笅妯″潡锛堜互 Maven 涓轰緥锛夛細 ```xml @@ -10,11 +10,11 @@ Sentinel 提供了与 Dubbo 整合的模块 - Sentinel Dubbo Adapter,主要包 ``` -引入此依赖后,Dubbo 的服务接口和方法(包括调用端和服务端)就会成为 Sentinel 中的资源,在配置了规则后就可以自动享受到 Sentinel 的防护能力。 +寮曞叆姝や緷璧栧悗锛孌ubbo 鐨勬湇鍔℃帴鍙e拰鏂规硶锛堝寘鎷皟鐢ㄧ鍜屾湇鍔$锛夊氨浼氭垚涓?Sentinel 涓殑璧勬簮锛屽湪閰嶇疆浜嗚鍒欏悗灏卞彲浠ヨ嚜鍔ㄤ韩鍙楀埌 Sentinel 鐨勯槻鎶よ兘鍔涖€? -> **注:若希望接入 Dashboard,请参考后面接入控制台的步骤。只引入 Sentinel Dubbo Adapter 无法接入控制台!** +> **娉細鑻ュ笇鏈涙帴鍏?Dashboard锛岃鍙傝€冨悗闈㈡帴鍏ユ帶鍒跺彴鐨勬楠ゃ€傚彧寮曞叆 Sentinel Dubbo Adapter 鏃犳硶鎺ュ叆鎺у埗鍙帮紒** -若不希望开启 Sentinel Dubbo Adapter 中的某个 Filter,可以手动关闭对应的 Filter,比如: +鑻ヤ笉甯屾湜寮€鍚?Sentinel Dubbo Adapter 涓殑鏌愪釜 Filter锛屽彲浠ユ墜鍔ㄥ叧闂搴旂殑 Filter锛屾瘮濡傦細 ```java @Bean @@ -25,88 +25,88 @@ public ConsumerConfig consumerConfig() { } ``` -我们提供了几个具体的 Demo 来分别演示 Provider 和 Consumer 的限流场景。 +鎴戜滑鎻愪緵浜嗗嚑涓叿浣撶殑 Demo 鏉ュ垎鍒紨绀?Provider 鍜?Consumer 鐨勯檺娴佸満鏅€? ## 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 涓嶈秴杩囦竴瀹氭暟鍊硷紝鍒欏彲浠ヤ负瀵瑰簲鏈嶅姟鎺ュ彛璧勬簮锛坮esourceName 涓?*鎺ュ彛鍏ㄩ檺瀹氬悕**锛夐厤缃?QPS 闃堝€硷紱鑻ュ笇鏈涙湇鍔$殑鏌愪釜鏂规硶鐨?QPS 涓嶈秴杩囦竴瀹氭暟鍊硷紝鍒欏彲浠ヤ负瀵瑰簲鏈嶅姟鏂规硶璧勬簮锛坮esourceName 涓?*鎺ュ彛鍏ㄩ檺瀹氬悕:鏂规硶绛惧悕**锛夐厤缃?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` 中: +Demo 1 婕旂ず浜嗘闄愭祦鍦烘櫙锛屾垜浠湅涓€涓嬭繖绉嶆ā寮忕殑闄愭祦浜х敓鐨勬晥鏋溿€傚亣璁炬垜浠凡缁忓畾涔変簡鏌愪釜鏈嶅姟鎺ュ彛 `com.alibaba.csp.sentinel.demo.dubbo.FooService`锛屽叾涓湁涓€涓柟娉?`sayHello(java.lang.String)`锛孭rovider 绔鏂规硶璁惧畾 QPS 闃堝€间负 10銆傚湪 Consumer 绔湪 1s 涔嬪唴杩炵画鍙戣捣 15 娆¤皟鐢紝鍙互閫氳繃鏃ュ織鏂囦欢鐪嬪埌 Provider 绔闄愭祦銆傛嫤鎴棩蹇楃粺涓€璁板綍鍦?`~/logs/csp/sentinel-block.log` 涓細 ```plaintext 2018-07-24 17:13:43|1|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String),FlowException,default,|5,0 ``` -在 Provider 对应的 metrics 日志中也有记录: +鍦?Provider 瀵瑰簲鐨?metrics 鏃ュ織涓篃鏈夎褰曪細 ```plaintext 1532423623000|2018-07-24 17:13:43|com.alibaba.csp.sentinel.demo.dubbo.FooService|15|0|15|0|3 1532423623000|2018-07-24 17:13:43|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String)|10|5|10|0|0 ``` -很多场景下,根据**调用方**来限流也是非常重要的。比如有两个服务 A 和 B 都向 Service Provider 发起调用请求,我们希望只对来自服务 B 的请求进行限流,则可以设置限流规则的 `limitApp` 为服务 B 的名称。Sentinel Dubbo Adapter 会自动解析 Dubbo 消费者(调用方)的 application name 作为调用方名称(`origin`),在进行资源保护的时候都会带上调用方名称。若限流规则未配置调用方(`default`),则该限流规则对所有调用方生效。若限流规则配置了调用方则限流规则将仅对指定调用方生效。 +寰堝鍦烘櫙涓嬶紝鏍规嵁**璋冪敤鏂?*鏉ラ檺娴佷篃鏄潪甯搁噸瑕佺殑銆傛瘮濡傛湁涓や釜鏈嶅姟 A 鍜?B 閮藉悜 Service Provider 鍙戣捣璋冪敤璇锋眰锛屾垜浠笇鏈涘彧瀵规潵鑷湇鍔?B 鐨勮姹傝繘琛岄檺娴侊紝鍒欏彲浠ヨ缃檺娴佽鍒欑殑 `limitApp` 涓烘湇鍔?B 鐨勫悕绉般€係entinel Dubbo Adapter 浼氳嚜鍔ㄨВ鏋?Dubbo 娑堣垂鑰咃紙璋冪敤鏂癸級鐨?application name 浣滀负璋冪敤鏂瑰悕绉帮紙`origin`锛夛紝鍦ㄨ繘琛岃祫婧愪繚鎶ょ殑鏃跺€欓兘浼氬甫涓婅皟鐢ㄦ柟鍚嶇О銆傝嫢闄愭祦瑙勫垯鏈厤缃皟鐢ㄦ柟锛坄default`锛夛紝鍒欒闄愭祦瑙勫垯瀵规墍鏈夎皟鐢ㄦ柟鐢熸晥銆傝嫢闄愭祦瑙勫垯閰嶇疆浜嗚皟鐢ㄦ柟鍒欓檺娴佽鍒欏皢浠呭鎸囧畾璋冪敤鏂圭敓鏁堛€? -> 注:Dubbo 默认通信不携带对端 application name 信息,因此需要开发者在调用端手动将 application name 置入 attachment 中,provider 端进行相应的解析。Sentinel Dubbo Adapter 实现了一个 Filter 用于自动从 consumer 端向 provider 端透传 application name。若调用端未引入 Sentinel Dubbo Adapter,又希望根据调用端限流,可以在调用端手动将 application name 置入 attachment 中,key 为 `dubboApplication`。 +> 娉細Dubbo 榛樿閫氫俊涓嶆惡甯﹀绔?application name 淇℃伅锛屽洜姝ら渶瑕佸紑鍙戣€呭湪璋冪敤绔墜鍔ㄥ皢 application name 缃叆 attachment 涓紝provider 绔繘琛岀浉搴旂殑瑙f瀽銆係entinel Dubbo Adapter 瀹炵幇浜嗕竴涓?Filter 鐢ㄤ簬鑷姩浠?consumer 绔悜 provider 绔€忎紶 application name銆傝嫢璋冪敤绔湭寮曞叆 Sentinel Dubbo Adapter锛屽張甯屾湜鏍规嵁璋冪敤绔檺娴侊紝鍙互鍦ㄨ皟鐢ㄧ鎵嬪姩灏?application name 缃叆 attachment 涓紝key 涓?`dubboApplication`銆? -在限流日志中会也会记录调用方的名称,如: +鍦ㄩ檺娴佹棩蹇椾腑浼氫篃浼氳褰曡皟鐢ㄦ柟鐨勫悕绉帮紝濡傦細 ```plaintext 2018-07-25 16:26:48|1|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String),FlowException,default,demo-consumer|5,0 ``` -其中日志中的 `demo-consumer` 即为调用方名称。 +鍏朵腑鏃ュ織涓殑 `demo-consumer` 鍗充负璋冪敤鏂瑰悕绉般€? ## Service Consumer -> 对服务消费方的流量控制可分为**控制并发线程数**和**服务降级**两个维度。 +> 瀵规湇鍔℃秷璐规柟鐨勬祦閲忔帶鍒跺彲鍒嗕负**鎺у埗骞跺彂绾跨▼鏁?*鍜?*鏈嶅姟闄嶇骇**涓や釜缁村害銆? -### 并发线程数限流 +### 骞跺彂绾跨▼鏁伴檺娴? -Service Consumer 作为客户端去调用远程服务。每一个服务都可能会依赖几个下游服务,若某个服务 A 依赖的下游服务 B 出现了不稳定的情况,服务 A 请求服务 B 的响应时间变长,从而服务 A 调用服务 B 的线程就会产生堆积,最终可能耗尽服务 A 的线程数。我们通过用并发线程数来控制对下游服务 B 的访问,来保证下游服务不可靠的时候,不会拖垮服务自身。基于这种场景,推荐给 Consumer 配置**线程数模式**的限流,来保证自身不被不稳定服务所影响。限流粒度同样可以是服务接口和服务方法两种粒度。 +Service Consumer 浣滀负瀹㈡埛绔幓璋冪敤杩滅▼鏈嶅姟銆傛瘡涓€涓湇鍔¢兘鍙兘浼氫緷璧栧嚑涓笅娓告湇鍔★紝鑻ユ煇涓湇鍔?A 渚濊禆鐨勪笅娓告湇鍔?B 鍑虹幇浜嗕笉绋冲畾鐨勬儏鍐碉紝鏈嶅姟 A 璇锋眰鏈嶅姟 B 鐨勫搷搴旀椂闂村彉闀匡紝浠庤€屾湇鍔?A 璋冪敤鏈嶅姟 B 鐨勭嚎绋嬪氨浼氫骇鐢熷爢绉紝鏈€缁堝彲鑳借€楀敖鏈嶅姟 A 鐨勭嚎绋嬫暟銆傛垜浠€氳繃鐢ㄥ苟鍙戠嚎绋嬫暟鏉ユ帶鍒跺涓嬫父鏈嶅姟 B 鐨勮闂紝鏉ヤ繚璇佷笅娓告湇鍔′笉鍙潬鐨勬椂鍊欙紝涓嶄細鎷栧灝鏈嶅姟鑷韩銆傚熀浜庤繖绉嶅満鏅紝鎺ㄨ崘缁?Consumer 閰嶇疆**绾跨▼鏁版ā寮?*鐨勯檺娴侊紝鏉ヤ繚璇佽嚜韬笉琚笉绋冲畾鏈嶅姟鎵€褰卞搷銆傞檺娴佺矑搴﹀悓鏍峰彲浠ユ槸鏈嶅姟鎺ュ彛鍜屾湇鍔℃柟娉曚袱绉嶇矑搴︺€? -采用基于线程数的限流模式后,我们不需要再显式地去进行线程池隔离,Sentinel 会控制资源的线程数,超出的请求直接拒绝,直到堆积的线程处理完成。 +閲囩敤鍩轰簬绾跨▼鏁扮殑闄愭祦妯″紡鍚庯紝鎴戜滑涓嶉渶瑕佸啀鏄惧紡鍦板幓杩涜绾跨▼姹犻殧绂伙紝Sentinel 浼氭帶鍒惰祫婧愮殑绾跨▼鏁帮紝瓒呭嚭鐨勮姹傜洿鎺ユ嫆缁濓紝鐩村埌鍫嗙Н鐨勭嚎绋嬪鐞嗗畬鎴愩€? -Demo 2 演示了此限流场景,我们看一下这种模式的效果。假设当前服务 A 依赖两个远程服务方法 `sayHello(java.lang.String)` 和 `doAnother()`。前者远程调用的响应时间 为 1s-1.5s之间,后者 RT 非常小(30 ms 左右)。服务 A 端设两个远程方法 thread count 为 5。然后每隔 50 ms 左右向线程池投入两个任务,作为消费者分别远程调用对应方法,持续 10 次。可以看到 `sayHello` 方法被限流 5 次,因为后面调用的时候前面的远程调用还未返回(RT 高);而 `doAnother()` 调用则不受影响。线程数目超出时快速失败能够有效地防止自己被慢调用所影响。 +Demo 2 婕旂ず浜嗘闄愭祦鍦烘櫙锛屾垜浠湅涓€涓嬭繖绉嶆ā寮忕殑鏁堟灉銆傚亣璁惧綋鍓嶆湇鍔?A 渚濊禆涓や釜杩滅▼鏈嶅姟鏂规硶 `sayHello(java.lang.String)` 鍜?`doAnother()`銆傚墠鑰呰繙绋嬭皟鐢ㄧ殑鍝嶅簲鏃堕棿 涓?1s-1.5s涔嬮棿锛屽悗鑰?RT 闈炲父灏忥紙30 ms 宸﹀彸锛夈€傛湇鍔?A 绔涓や釜杩滅▼鏂规硶 thread count 涓?5銆傜劧鍚庢瘡闅?50 ms 宸﹀彸鍚戠嚎绋嬫睜鎶曞叆涓や釜浠诲姟锛屼綔涓烘秷璐硅€呭垎鍒繙绋嬭皟鐢ㄥ搴旀柟娉曪紝鎸佺画 10 娆°€傚彲浠ョ湅鍒?`sayHello` 鏂规硶琚檺娴?5 娆★紝鍥犱负鍚庨潰璋冪敤鐨勬椂鍊欏墠闈㈢殑杩滅▼璋冪敤杩樻湭杩斿洖锛圧T 楂橈級锛涜€?`doAnother()` 璋冪敤鍒欎笉鍙楀奖鍝嶃€傜嚎绋嬫暟鐩秴鍑烘椂蹇€熷け璐ヨ兘澶熸湁鏁堝湴闃叉鑷繁琚參璋冪敤鎵€褰卞搷銆? -### 服务降级 +### 鏈嶅姟闄嶇骇 -当服务依赖于多个下游服务,而某个下游服务调用非常慢时,会严重影响当前服务的调用。这里我们可以利用 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 -从 0.1.1 版本开始,Sentinel Dubbo Adapter 还支持配置全局的 fallback 函数,可以在 Dubbo 服务被限流/降级/负载保护的时候进行相应的 fallback 处理。用户只需要实现自定义的 [`DubboFallback`](https://github.com/alibaba/Sentinel/blob/master/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallback.java) 接口,并通过 `DubboFallbackRegistry` 注册即可。默认情况会直接将 `BlockException` 包装后抛出。同时,我们还可以配合 [Dubbo 的 fallback 机制](http://dubbo.apache.org/#!/docs/user/demos/local-mock.md?lang=zh-cn) 来为降级的服务提供替代的实现。 +浠?0.1.1 鐗堟湰寮€濮嬶紝Sentinel Dubbo Adapter 杩樻敮鎸侀厤缃叏灞€鐨?fallback 鍑芥暟锛屽彲浠ュ湪 Dubbo 鏈嶅姟琚檺娴?闄嶇骇/璐熻浇淇濇姢鐨勬椂鍊欒繘琛岀浉搴旂殑 fallback 澶勭悊銆傜敤鎴峰彧闇€瑕佸疄鐜拌嚜瀹氫箟鐨?[`DubboFallback`](https://github.com/alibaba/Sentinel/blob/master/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallback.java) 鎺ュ彛锛屽苟閫氳繃 `DubboFallbackRegistry` 娉ㄥ唽鍗冲彲銆傞粯璁ゆ儏鍐典細鐩存帴灏?`BlockException` 鍖呰鍚庢姏鍑恒€傚悓鏃讹紝鎴戜滑杩樺彲浠ラ厤鍚?[Dubbo 鐨?fallback 鏈哄埗](http://dubbo.apache.org/#!/docs/user/demos/local-mock.md?lang=zh-cn) 鏉ヤ负闄嶇骇鐨勬湇鍔℃彁渚涙浛浠g殑瀹炵幇銆? -Demo 2 的 Consumer 端提供了一个简单的 fallback 示例。 +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 杩樻彁渚涗簡涓€涓帶鍒跺彴锛圖ashboard锛夌敤浜庨厤缃鍒欍€佹煡鐪嬬洃鎺с€佹満鍣ㄥ彂鐜扮瓑鍔熻兘銆? -接入 Dashboard 的步骤(**缺一不可**): +鎺ュ叆 Dashboard 鐨勬楠わ紙**缂轰竴涓嶅彲**锛夛細 -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,用于上报相关信息 - - `-Dcsp.sentinel.dashboard.server`:控制台的地址 - - `-Dproject.name`:应用名称,会在控制台中显示 +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锛岀敤浜庝笂鎶ョ浉鍏充俊鎭? + - `-Dcsp.sentinel.dashboard.server`锛氭帶鍒跺彴鐨勫湴鍧€ + - `-Dproject.name`锛氬簲鐢ㄥ悕绉帮紝浼氬湪鎺у埗鍙颁腑鏄剧ず -注意某些环境下本地运行 Dubbo 服务还需要加上 `-Djava.net.preferIPv4Stack=true` 参数。比如 Service Provider 示例的启动参数: +娉ㄦ剰鏌愪簺鐜涓嬫湰鍦拌繍琛?Dubbo 鏈嶅姟杩橀渶瑕佸姞涓?`-Djava.net.preferIPv4Stack=true` 鍙傛暟銆傛瘮濡?Service Provider 绀轰緥鐨勫惎鍔ㄥ弬鏁帮細 ```bash -Djava.net.preferIPv4Stack=true -Dcsp.sentinel.api.port=8720 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=dubbo-provider-demo ``` -Service Consumer 示例的启动参数: +Service Consumer 绀轰緥鐨勫惎鍔ㄥ弬鏁帮細 ```bash -Djava.net.preferIPv4Stack=true -Dcsp.sentinel.api.port=8721 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=dubbo-consumer-demo ``` -这样在启动 Service Provider 和 Service Consumer 示例以后,就可以在 Sentinel 控制台中找到我们的服务了。可以很方便地在控制台中配置限流规则: +杩欐牱鍦ㄥ惎鍔?Service Provider 鍜?Service Consumer 绀轰緥浠ュ悗锛屽氨鍙互鍦?Sentinel 鎺у埗鍙颁腑鎵惧埌鎴戜滑鐨勬湇鍔′簡銆傚彲浠ュ緢鏂逛究鍦板湪鎺у埗鍙颁腑閰嶇疆闄愭祦瑙勫垯锛? -![规则配置](http://dubbo.incubator.apache.org/img/blog/sentinel-dashboard-view-rules.png) +![瑙勫垯閰嶇疆](http://dubbo.incubator.apache.org/img/blog/sentinel-dashboard-view-rules.png) -或者查看实时监控数据: +鎴栬€呮煡鐪嬪疄鏃剁洃鎺ф暟鎹細 -![秒级实时监控](http://dubbo.incubator.apache.org/img/blog/sentinel-dashboard-metrics.png) +![绉掔骇瀹炴椂鐩戞帶](http://dubbo.incubator.apache.org/img/blog/sentinel-dashboard-metrics.png) diff --git a/sentinel-extension/sentinel-parameter-flow-control/README.md b/sentinel-extension/sentinel-parameter-flow-control/README.md index d28157c4ce..08ddf979df 100644 --- a/sentinel-extension/sentinel-parameter-flow-control/README.md +++ b/sentinel-extension/sentinel-parameter-flow-control/README.md @@ -1,4 +1,4 @@ -# Sentinel Parameter Flow Control +# Sentinel Parameter Flow Control This component provides functionality of flow control by frequent ("hot spot") parameters. @@ -48,12 +48,6 @@ ParamFlowRuleManager.loadRules(Collections.singletonList(rule)); The description for fields of `ParamFlowRule`: -|Field|Description|Default| -|:---:|:---|:---| -|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| | +|Field|Description|Default||:---:|:---|:---||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|| Now the parameter flow control rules will take effect. From abce6b667826b5b3b5c48f325d00a300d27d12d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=B0=A7?= Date: Tue, 16 Dec 2025 14:56:22 +0800 Subject: [PATCH 5/9] docs: fix table format in parameter-flow-control README (MD060/MD009) --- .../sentinel-parameter-flow-control/README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sentinel-extension/sentinel-parameter-flow-control/README.md b/sentinel-extension/sentinel-parameter-flow-control/README.md index 08ddf979df..532150330b 100644 --- a/sentinel-extension/sentinel-parameter-flow-control/README.md +++ b/sentinel-extension/sentinel-parameter-flow-control/README.md @@ -48,6 +48,12 @@ ParamFlowRuleManager.loadRules(Collections.singletonList(rule)); The description for fields of `ParamFlowRule`: -|Field|Description|Default||:---:|:---|:---||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|| +| Field | Description | Default | +| :---: | :--- | :--- | +| 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 | | Now the parameter flow control rules will take effect. From 4412b35219947ff5c3da22abe8d3fc5a50464267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=B0=A7?= Date: Tue, 16 Dec 2025 15:03:46 +0800 Subject: [PATCH 6/9] docs: fix table format in spring-webmvc README files (MD060/MD009) --- .../sentinel-spring-webmvc-adapter/README.md | 21 +++++++++++++- .../README.md | 28 +++++++++---------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md b/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md index a8f87c5072..a44557839a 100755 --- a/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md +++ b/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md @@ -91,4 +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`|-|- `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`|- `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 | +| ------ | ------------ | ------ | ------- | +| `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` | + +- `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` | diff --git a/sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/README.md b/sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/README.md index b45a2ca02c..718e4f2c3e 100755 --- a/sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/README.md +++ b/sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/README.md @@ -85,23 +85,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` | From 465f6dc34db65831fb79a542133ea82388078870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=B0=A7?= Date: Tue, 16 Dec 2025 16:42:33 +0800 Subject: [PATCH 7/9] fix: restore UTF-8 encoding and fix markdownlint errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Restore correct UTF-8 encoding for all Chinese text - Fix garbled Chinese in company logos (拼多多, 爱奇艺, 二维火, etc.) - Fix table column style (MD060) - remove spaces around pipes - Fix bare URLs (MD034) - wrap URLs with angle brackets - Remove BOM markers from documentation files Fixes encoding issues from commit 7b9f7c78 Disabled core.autocrlf to prevent encoding corruption --- README.md | 40 ++++----- .../sentinel-spring-webmvc-adapter/README.md | 30 +++---- .../README.md | 8 +- sentinel-dashboard/README.md | 61 ++++++------- .../Sentinel_Dashboard_Feature.md | 86 +++++++++---------- sentinel-demo/sentinel-demo-dubbo/README.md | 72 ++++++++-------- 6 files changed, 152 insertions(+), 145 deletions(-) diff --git a/README.md b/README.md index 3e76d41459..ac11e1ab63 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Sentinel: The Sentinel of Your Microservices +# Sentinel: The Sentinel of Your Microservices Sentinel Logo @@ -18,7 +18,7 @@ to guarantee reliability and resilience for microservices. Sentinel has the following features: -- **Rich applicable scenarios**: Sentinel has been wildly used in Alibaba, and has covered almost all the core-scenarios in Double-11 (11.11) Shopping Festivals in the past 10 years, such as 鈥淪econd Kill鈥?which needs to limit burst flow traffic to meet the system capacity, message peak clipping and valley fills, circuit breaking for unreliable downstream services, cluster flow control, etc. +- **Rich applicable scenarios**: Sentinel has been wildly used in Alibaba, and has covered almost all the core-scenarios in Double-11 (11.11) Shopping Festivals in the past 10 years, such as “Second Kill” which needs to limit burst flow traffic to meet the system capacity, message peak clipping and valley fills, circuit breaking for unreliable downstream services, cluster flow control, etc. - **Real-time monitoring**: Sentinel also provides real-time monitoring ability. You can see the runtime information of a single machine in real-time, and the aggregated runtime info of a cluster with less than 500 nodes. - **Widespread open-source ecosystem**: Sentinel provides out-of-box integrations with commonly-used frameworks and libraries such as Spring Cloud, gRPC, Apache Dubbo and Quarkus. You can easily use Sentinel by simply add the adapter dependency to your services. - **Polyglot support**: Sentinel has provided native support for Java, [Go](https://github.com/alibaba/sentinel-golang), [C++](https://github.com/alibaba/sentinel-cpp) and [Rust](https://github.com/sentinel-group/sentinel-rust). @@ -35,7 +35,7 @@ Please refer to [OpenSergo](https://opensergo.io/) for details. See the [Sentinel Website](https://sentinelguard.io/) for the official website of Sentinel. -See the [涓枃鏂囨。](https://sentinelguard.io/zh-cn/docs/introduction.html) for document in Chinese. +See the [中文文档](https://sentinelguard.io/zh-cn/docs/introduction.html) for document in Chinese. See the [Wiki](https://github.com/alibaba/Sentinel/wiki) for full documentation, examples, blog posts, operational details and other information. @@ -112,13 +112,13 @@ For more information, please refer to [How To Use](https://sentinelguard.io/en-u After running the demo for a while, you can see the following records in `~/logs/csp/${appName}-metrics.log.{date}` (When using the default `DateFileLogHandler`). ```plaintext -|--timestamp-|------date time----|-resource-|p|block|s|e|rt|occupied -1529998904000|2018-06-26 15:41:44|HelloWorld|20|0|20|0|0|0 -1529998905000|2018-06-26 15:41:45|HelloWorld|20|5579|20|0|728|0 -1529998906000|2018-06-26 15:41:46|HelloWorld|20|15698|20|0|0|0 -1529998907000|2018-06-26 15:41:47|HelloWorld|20|19262|20|0|0|0 -1529998908000|2018-06-26 15:41:48|HelloWorld|20|19502|20|0|0|0 -1529998909000|2018-06-26 15:41:49|HelloWorld|20|18386|20|0|0|0 +|--timestamp-|------date time----|-resource-|p |block|s |e|rt |occupied +1529998904000|2018-06-26 15:41:44|HelloWorld|20|0 |20|0|0 |0 +1529998905000|2018-06-26 15:41:45|HelloWorld|20|5579 |20|0|728 |0 +1529998906000|2018-06-26 15:41:46|HelloWorld|20|15698|20|0|0 |0 +1529998907000|2018-06-26 15:41:47|HelloWorld|20|19262|20|0|0 |0 +1529998908000|2018-06-26 15:41:48|HelloWorld|20|19502|20|0|0 |0 +1529998909000|2018-06-26 15:41:49|HelloWorld|20|18386|20|0|0 |0 p stands for incoming request, block for blocked by rules, s for success handled by Sentinel, e for exception count, rt for average response time (ms), occupied stands for occupiedPassQps since 1.5.0 which enable us booking more than 1 shot when entering. ``` @@ -160,9 +160,9 @@ You can start with the issues labeled with [`good first issue`](https://github.c ## Enterprise Service -If you need Sentinel enterprise service support (Sentinel 浼佷笟鐗?, or purchase cloud product services, +If you need Sentinel enterprise service support (Sentinel 企业版), or purchase cloud product services, you can join the discussion by the DingTalk group (34754806). It can also be directly activated -and used through the [microservice engine (MSE 寰湇鍔″紩鎿? provided by Alibaba Cloud](https://cn.aliyun.com/product/aliware/mse?spm=sentinel-github.index.0.0.0). +and used through the [microservice engine (MSE 微服务引擎) provided by Alibaba Cloud](https://cn.aliyun.com/product/aliware/mse?spm=sentinel-github.index.0.0.0). ## Credits @@ -178,13 +178,13 @@ If you are using Sentinel, please [add your company here](https://github.com/ali ![Alibaba Group](https://docs.alibabagroup.com/assets2/images/en/global/logo_header.png) ![AntFin](https://user-images.githubusercontent.com/9434884/90598732-30961c00-e226-11ea-8c86-0b1d7f7875c7.png) ![Taiping Renshou](http://www.cntaiping.com/tplresource/cms/www/taiping/img/home_new/tp_logo_img.png) -![鎷煎澶歖(http://cdn.pinduoduo.com/assets/img/pdd_logo_v3.png) -![鐖卞鑹篯(https://user-images.githubusercontent.com/9434884/90598445-a51c8b00-e225-11ea-9327-3543525f3f2a.png) +![拼多多](http://cdn.pinduoduo.com/assets/img/pdd_logo_v3.png) +![爱奇艺](https://user-images.githubusercontent.com/9434884/90598445-a51c8b00-e225-11ea-9327-3543525f3f2a.png) ![Shunfeng Technology](https://user-images.githubusercontent.com/9434884/48463502-2f48eb80-e817-11e8-984f-2f9b1b789e2d.png) -![浜岀淮鐏玗(https://user-images.githubusercontent.com/9434884/49358468-bc43de00-f70d-11e8-97fe-0bf05865f29f.png) +![二维火](https://user-images.githubusercontent.com/9434884/49358468-bc43de00-f70d-11e8-97fe-0bf05865f29f.png) ![Mandao](https://user-images.githubusercontent.com/9434884/48463559-6cad7900-e817-11e8-87e4-42952b074837.png) -![鏂囪僵鍦ㄧ嚎](http://static.winxuancdn.com/css/v2/images/logo.png) -![瀹㈠浜慮(https://www.keruyun.com/static/krynew/images/logo.png) -![浜插疂瀹漖(https://stlib.qbb6.com/wclt/img/home_hd/version1/title_logo.png) -![閲戞眹閲戣瀺](https://res.jinhui365.com/r/images/logo2.png?v=1.527) -![闂數璐璢(http://cdn.52shangou.com/shandianbang/official-source/3.1.1/build/images/logo.png) +![文轩在线](http://static.winxuancdn.com/css/v2/images/logo.png) +![客如云](https://www.keruyun.com/static/krynew/images/logo.png) +![亲宝宝](https://stlib.qbb6.com/wclt/img/home_hd/version1/title_logo.png) +![金汇金融](https://res.jinhui365.com/r/images/logo2.png?v=1.527) +![闪电购](http://cdn.52shangou.com/shandianbang/official-source/3.1.1/build/images/logo.png) diff --git a/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md b/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md index a44557839a..59e90f814c 100755 --- a/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md +++ b/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md @@ -1,4 +1,4 @@ -# Sentinel Spring MVC Adapter +# Sentinel Spring MVC Adapter ## Introduction @@ -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` | diff --git a/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md b/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md index 1dd0940187..0acfde911a 100644 --- a/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md +++ b/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md @@ -1,4 +1,4 @@ -# Sentinel Token Server (Envoy RLS implementation) +# Sentinel Token Server (Envoy RLS implementation) This module provides the [Envoy rate limiting gRPC service](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/other_features/global_rate_limiting#arch-overview-rate-limit) implementation with Sentinel token server. @@ -50,7 +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 diff --git a/sentinel-dashboard/README.md b/sentinel-dashboard/README.md index 51a3650cbc..22ed623838 100755 --- a/sentinel-dashboard/README.md +++ b/sentinel-dashboard/README.md @@ -1,22 +1,22 @@ -# Sentinel 鎺у埗鍙? +# Sentinel 控制台 -## 0. 姒傝堪 +## 0. 概述 -Sentinel 鎺у埗鍙版槸娴侀噺鎺у埗銆佺啍鏂檷绾ц鍒欑粺涓€閰嶇疆鍜岀鐞嗙殑鍏ュ彛锛屽畠涓虹敤鎴锋彁渚涗簡鏈哄櫒鑷彂鐜般€佺皣鐐归摼璺嚜鍙戠幇銆佺洃鎺с€佽鍒欓厤缃瓑鍔熻兘銆傚湪 Sentinel 鎺у埗鍙颁笂锛屾垜浠彲浠ラ厤缃鍒欏苟瀹炴椂鏌ョ湅娴侀噺鎺у埗鏁堟灉銆? +Sentinel 控制台是流量控制、熔断降级规则统一配置和管理的入口,它为用户提供了机器自发现、簇点链路自发现、监控、规则配置等功能。在 Sentinel 控制台上,我们可以配置规则并实时查看流量控制效果。 -## 1. 缂栬瘧鍜屽惎鍔? +## 1. 编译和启动 -### 1.1 濡備綍缂栬瘧 +### 1.1 如何编译 -浣跨敤濡備笅鍛戒护灏嗕唬鐮佹墦鍖呮垚涓€涓?fat jar: +使用如下命令将代码打包成一个 fat jar: ```bash mvn clean package ``` -### 1.2 濡備綍鍚姩 +### 1.2 如何启动 -浣跨敤濡備笅鍛戒护鍚姩缂栬瘧鍚庣殑鎺у埗鍙帮細 +使用如下命令启动编译后的控制台: ```bash java -Dserver.port=8080 \ @@ -25,42 +25,45 @@ java -Dserver.port=8080 \ -jar target/sentinel-dashboard.jar ``` -涓婅堪鍛戒护涓垜浠寚瀹氬嚑涓?JVM 鍙傛暟锛屽叾涓?`-Dserver.port=8080` 鏄?Spring Boot 鐨勫弬鏁帮紝 -鐢ㄤ簬鎸囧畾 Spring Boot 鏈嶅姟绔惎鍔ㄧ鍙d负 `8080`銆傚叾浣欏嚑涓槸 Sentinel 瀹㈡埛绔殑鍙傛暟銆? +上述命令中我们指定几个 JVM 参数,其中 `-Dserver.port=8080` 是 Spring Boot 的参数, +用于指定 Spring Boot 服务端启动端口为 `8080`。其余几个是 Sentinel 客户端的参数。 -涓轰究浜庢紨绀猴紝鎴戜滑瀵规帶鍒跺彴鏈韩鍔犲叆浜嗘祦閲忔帶鍒跺姛鑳斤紝鍏蜂綋鍋氭硶鏄紩鍏?Sentinel 鎻愪緵鐨?`CommonFilter` 杩欎釜 Servlet Filter銆? -涓婅堪 JVM 鍙傛暟鐨勫惈涔夋槸锛? +为便于演示,我们对控制台本身加入了流量控制功能,具体做法是引入 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)銆? +全部的配置项可以参考 [启动配置项文档](https://github.com/alibaba/Sentinel/wiki/%E5%90%AF%E5%8A%A8%E9%85%8D%E7%BD%AE%E9%A1%B9)。 -缁忚繃涓婅堪閰嶇疆锛屾帶鍒跺彴鍚姩鍚庝細鑷姩鍚戣嚜宸卞彂閫佸績璺炽€傜▼搴忓惎鍔ㄥ悗娴忚鍣ㄨ闂?`localhost:8080` 鍗冲彲璁块棶 Sentinel 鎺у埗鍙般€? +经过上述配置,控制台启动后会自动向自己发送心跳。程序启动后浏览器访问 `localhost:8080` 即可访问 Sentinel 控制台。 -浠?Sentinel 1.6.0 寮€濮嬶紝Sentinel 鎺у埗鍙版敮鎸佺畝鍗曠殑**鐧诲綍**鍔熻兘锛岄粯璁ょ敤鎴峰悕鍜屽瘑鐮侀兘鏄?`sentinel`銆傜敤鎴峰彲浠ラ€氳繃濡備笅鍙傛暟杩涜閰嶇疆锛? +从 Sentinel 1.6.0 开始,Sentinel 控制台支持简单的**登录**功能,默认用户名和密码都是 `sentinel`。用户可以通过如下参数进行配置: -- `-Dsentinel.dashboard.auth.username=sentinel` 鐢ㄤ簬鎸囧畾鎺у埗鍙扮殑鐧诲綍鐢ㄦ埛鍚嶄负 `sentinel`锛? -- `-Dsentinel.dashboard.auth.password=123456` 鐢ㄤ簬鎸囧畾鎺у埗鍙扮殑鐧诲綍瀵嗙爜涓?`123456`锛涘鏋滅渷鐣ヨ繖涓や釜鍙傛暟锛岄粯璁ょ敤鎴峰拰瀵嗙爜鍧囦负 `sentinel`锛? -- `-Dserver.servlet.session.timeout=7200` 鐢ㄤ簬鎸囧畾 Spring Boot 鏈嶅姟绔?session 鐨勮繃鏈熸椂闂达紝濡?`7200` 琛ㄧず 7200 绉掞紱`60m` 琛ㄧず 60 鍒嗛挓锛岄粯璁や负 30 鍒嗛挓锛? +- `-Dsentinel.dashboard.auth.username=sentinel` 用于指定控制台的登录用户名为 `sentinel`; +- `-Dsentinel.dashboard.auth.password=123456` 用于指定控制台的登录密码为 `123456`;如果省略这两个参数,默认用户和密码均为 `sentinel`; +- `-Dserver.servlet.session.timeout=7200` 用于指定 Spring Boot 服务端 session 的过期时间,如 `7200` 表示 7200 秒;`60m` 表示 60 分钟,默认为 30 分钟; -## 2. 瀹㈡埛绔帴鍏? +## 2. 客户端接入 -閫夋嫨鍚堥€傜殑鏂瑰紡鎺ュ叆 Sentinel锛岀劧鍚庡湪搴旂敤鍚姩鏃跺姞鍏?JVM 鍙傛暟 `-Dcsp.sentinel.dashboard.server=consoleIp:port` 鎸囧畾鎺у埗鍙板湴鍧€鍜岀鍙c€? -纭繚瀹㈡埛绔湁璁块棶閲忥紝**Sentinel 浼氬湪瀹㈡埛绔娆¤皟鐢ㄧ殑鏃跺€欒繘琛屽垵濮嬪寲锛屽紑濮嬪悜鎺у埗鍙板彂閫佸績璺冲寘**锛屽皢瀹㈡埛绔撼鍏ュ埌鎺у埗鍙扮殑绠¤緰涔嬩笅銆? +选择合适的方式接入 Sentinel,然后在应用启动时加入 JVM 参数 `-Dcsp.sentinel.dashboard.server=consoleIp:port` 指定控制台地址和端口。 +确保客户端有访问量,**Sentinel 会在客户端首次调用的时候进行初始化,开始向控制台发送心跳包**,将客户端纳入到控制台的管辖之下。 -瀹㈡埛绔帴鍏ョ殑璇︾粏姝ラ璇峰弬鑰?[Wiki 鏂囨。](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0#3-%E5%AE%A2%E6%88%B7%E7%AB%AF%E6%8E%A5%E5%85%A5%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#3-%E5%AE%A2%E6%88%B7%E7%AB%AF%E6%8E%A5%E5%85%A5%E6%8E%A7%E5%88%B6%E5%8F%B0)。 -## 3. 楠岃瘉鏄惁鎺ュ叆鎴愬姛 +## 3. 验证是否接入成功 -瀹㈡埛绔纭厤缃苟鍚姩鍚庯紝浼?*鍦ㄥ垵娆¤皟鐢ㄥ悗**涓诲姩鍚戞帶鍒跺彴鍙戦€佸績璺冲寘锛屾眹鎶ヨ嚜宸辩殑瀛樺湪锛? -鎺у埗鍙版敹鍒板鎴风蹇冭烦鍖呬箣鍚庯紝浼氬湪宸︿晶瀵艰埅鏍忎腑鏄剧ず璇ュ鎴风淇℃伅銆傚鏋滄帶鍒跺彴鑳藉鐪嬪埌瀹㈡埛绔殑鏈哄櫒淇℃伅锛屽垯琛ㄦ槑瀹㈡埛绔帴鍏ユ垚鍔熶簡銆? +客户端正确配置并启动后,会**在初次调用后**主动向控制台发送心跳包,汇报自己的存在; +控制台收到客户端心跳包之后,会在左侧导航栏中显示该客户端信息。如果控制台能够看到客户端的机器信息,则表明客户端接入成功了。 -## 6. 鏋勫缓Docker闀滃儚 +## 6. 构建Docker镜像 ```bash docker build --build-arg SENTINEL_VERSION=1.8.9 -t ${REGISTRY}/sentinel-dashboard:v1.8.9 . ``` -*娉ㄦ剰锛歋entinel 鎺у埗鍙扮洰鍓嶄粎鏀寔鍗曟満閮ㄧ讲銆係entinel 鎺у埗鍙伴」鐩彁渚?Sentinel 鍔熻兘鍏ㄩ泦绀轰緥锛屼笉浣滀负寮€绠卞嵆鐢ㄧ殑鐢熶骇鐜鎺у埗鍙帮紝涓嶆彁渚涘畨鍏ㄥ彲闈犱繚闅溿€傝嫢甯屾湜鍦ㄧ敓浜х幆澧冧娇鐢ㄨ鏍规嵁[鏂囨。](https://github.com/alibaba/Sentinel/wiki/%E5%9C%A8%E7%94%9F%E4%BA%A7%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%BD%BF%E7%94%A8-Sentinel)鑷杩涜瀹氬埗鍜屾敼閫犮€? +*注意:Sentinel 控制台目前仅支持单机部署。Sentinel 控制台项目提供 Sentinel 功能全集示例,不作为开箱即用的生产环境控制台,不提供安全可靠保障。若希望在生产环境使用请根据[文档](https://github.com/alibaba/Sentinel/wiki/%E5%9C%A8%E7%94%9F%E4%BA%A7%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%BD%BF%E7%94%A8-Sentinel)自行进行定制和改造。* -鏇村锛歔鎺у埗鍙板姛鑳戒粙缁峕(./Sentinel_Dashboard_Feature.md)銆? +更多:[控制台功能介绍](./Sentinel_Dashboard_Feature.md)。 diff --git a/sentinel-dashboard/Sentinel_Dashboard_Feature.md b/sentinel-dashboard/Sentinel_Dashboard_Feature.md index 50ad6d92d1..4fe4867970 100755 --- a/sentinel-dashboard/Sentinel_Dashboard_Feature.md +++ b/sentinel-dashboard/Sentinel_Dashboard_Feature.md @@ -1,88 +1,88 @@ -# Sentinel 鎺у埗鍙板姛鑳戒粙缁? +# Sentinel 控制台功能介绍 -## 0. 姒傝堪 +## 0. 概述 -Sentinel 鎺у埗鍙版槸娴侀噺鎺у埗銆佺啍鏂檷绾ц鍒欑粺涓€閰嶇疆鍜岀鐞嗙殑鍏ュ彛锛屽畠涓虹敤鎴锋彁渚涗簡鏈哄櫒鑷彂鐜般€佺皣鐐归摼璺嚜鍙戠幇銆佺洃鎺с€佽鍒欓厤缃瓑鍔熻兘銆傚湪 Sentinel 鎺у埗鍙颁笂锛屾垜浠彲浠ラ厤缃鍒欏苟瀹炴椂鏌ョ湅娴侀噺鎺у埗鏁堟灉銆備娇鐢?Sentinel 鎺у埗鍙扮殑娴佺▼濡備笅锛? +Sentinel 控制台是流量控制、熔断降级规则统一配置和管理的入口,它为用户提供了机器自发现、簇点链路自发现、监控、规则配置等功能。在 Sentinel 控制台上,我们可以配置规则并实时查看流量控制效果。使用 Sentinel 控制台的流程如下: ```plaintext -瀹㈡埛绔帴鍏?-> 鏈哄櫒鑷彂鐜?-> 鏌ョ湅绨囩偣閾捐矾 -> 閰嶇疆娴佹帶瑙勫垯 -> 鏌ョ湅娴佹帶鏁堟灉 +客户端接入 -> 机器自发现 -> 查看簇点链路 -> 配置流控规则 -> 查看流控效果 ``` -## 1. 鍔熻兘浠嬬粛 +## 1. 功能介绍 -### 1.1 鏈哄櫒鑷彂鐜? +### 1.1 机器自发现 -Sentinel 鎻愪緵鍐呯疆鐨勬満鍣ㄨ嚜鍙戠幇鍔熻兘锛屾棤闇€渚濊禆绗笁鏂规湇鍔″彂鐜扮粍浠跺嵆鍙疄鐜板鎴风鐨勫彂鐜般€傜偣鍑?Sentinel 鎺у埗鍙板乏渚у鑸爮鐨勨€滄満鍣ㄥ垪琛ㄢ€濊彍鍗曪紝鍙煡鐪嬮泦缇ゆ満鍣ㄦ暟閲忓拰鏈哄櫒鍋ュ悍鐘跺喌銆? +Sentinel 提供内置的机器自发现功能,无需依赖第三方服务发现组件即可实现客户端的发现。点击 Sentinel 控制台左侧导航栏的“机器列表”菜单,可查看集群机器数量和机器健康状况。 -### 1.2 绨囩偣閾捐矾鑷彂鐜? +### 1.2 簇点链路自发现 -Sentinel 灏嗘瘡涓€涓渶瑕佹祦鎺х殑 URL 鎴栬€呮帴鍙gО涓轰竴涓祫婧愶紝骞朵娇鐢║RL鍦板潃鎴栨柟娉曠鍚嶈〃绀鸿祫婧愩€係entinel 浼氳嚜鍔ㄥ彂鐜版墍鏈夋綔鍦ㄧ殑璧勬簮鍜岃祫婧愪箣闂寸殑璋冪敤閾撅紝骞跺湪鈥滅皣鐐归摼璺€濋〉闈㈠睍绀恒€? -璧勬簮鏄缃祦鎺ц鍒欑殑杞戒綋锛岄€氳繃绨囩偣閾捐矾鑷彂鐜帮紝鍙互鏂逛究鐨勫閲嶈璧勬簮璁剧疆娴佹帶瑙勫垯銆佺啍鏂檷绾ц鍒欑瓑銆? +Sentinel 将每一个需要流控的 URL 或者接口称为一个资源,并使用URL地址或方法签名表示资源。Sentinel 会自动发现所有潜在的资源和资源之间的调用链,并在“簇点链路”页面展示。 +资源是设置流控规则的载体,通过簇点链路自发现,可以方便的对重要资源设置流控规则、熔断降级规则等。 -> 娉ㄦ剰锛?*瀹㈡埛绔湁璁块棶閲忎箣鍚庯紝鎵嶈兘鍦ㄧ皣鐐归摼璺〉闈㈢湅鍒拌祫婧愮洃鎺э紙lazy-initializing锛?*銆? +> 注意:**客户端有访问量之后,才能在簇点链路页面看到资源监控(lazy-initializing)**。 -### 1.3 瀹炴椂鐩戞帶 +### 1.3 实时监控 -Sentinel 鐩戞帶鍔熻兘鑳藉瀹炴椂鏌ョ湅闆嗙兢涓瘡涓祫婧愮殑瀹炴椂璁块棶浠ュ強娴佹帶鎯呭喌銆傛帶鍒跺彴宸︿晶瀵艰埅鏍忕殑鈥滃疄鏃剁洃鎺р€濊彍鍗曞搴旇鍔熻兘銆? +Sentinel 监控功能能够实时查看集群中每个资源的实时访问以及流控情况。控制台左侧导航栏的“实时监控”菜单对应该功能。 -### 1.4 娴佹帶闄嶇骇瑙勫垯璁剧疆 +### 1.4 流控降级规则设置 -Sentinel 鎻愪緵浜嗗绉嶈鍒欐潵淇濇姢绯荤粺鐨勪笉鍚岄儴鍒嗐€傛祦閲忔帶鍒惰鍒欑敤浜庝繚鎶ゆ湇鍔℃彁渚涙柟锛岀啍鏂檷绾ц鍒欑敤浜庝繚鎶ゆ湇鍔℃秷璐规柟锛岀郴缁熶繚鎶よ鍒欑敤浜庝繚鎶ゆ暣涓郴缁熴€? +Sentinel 提供了多种规则来保护系统的不同部分。流量控制规则用于保护服务提供方,熔断降级规则用于保护服务消费方,系统保护规则用于保护整个系统。 -#### 1.4.1 娴侀噺鎺у埗瑙勫垯 +#### 1.4.1 流量控制规则 -娴侀噺鎺у埗瑙勫垯鐢ㄤ簬淇濇姢鏈嶅姟鎻愪緵鏂癸紝鏈嶅姟鎻愪緵鏂规寚浠讳綍鍙互瀵瑰鎻愪緵鏈嶅姟鐨勭郴缁燂紝姣斿鍚戠粓绔敤鎴锋彁渚?Web 鏈嶅姟鐨?Web 搴旂敤锛屽悜寰湇鍔℃秷璐规柟鎻愪緵鏈嶅姟鐨?Dubbo Service Provider 绛夈€? -绯荤粺鐨勬湇鍔¤兘鍔涙槸鏈夐檺鐨勶紝濡傛灉娑堣垂鏂硅姹傞€熷害杩囬珮锛屽垯閲囩敤鐩稿簲鐨勪繚鎶ょ瓥鐣ワ紝鎴栨槸鐩存帴鎷掔粷锛屾垨鏄帓闃熺瓑寰呫€傞€氳繃鈥滄祦鎺ц鍒欌€濋〉闈㈠彲浠ユ煡鐪嬪拰閰嶇疆娴侀噺鎺у埗瑙勫垯銆? +流量控制规则用于保护服务提供方,服务提供方指任何可以对外提供服务的系统,比如向终端用户提供 Web 服务的 Web 应用,向微服务消费方提供服务的 Dubbo Service Provider 等。 +系统的服务能力是有限的,如果消费方请求速度过高,则采用相应的保护策略,或是直接拒绝,或是排队等待。通过“流控规则”页面可以查看和配置流量控制规则。 -#### 1.4.2 鐔旀柇闄嶇骇瑙勫垯 +#### 1.4.2 熔断降级规则 -闄嶇骇瑙勫垯鐢ㄤ簬淇濇姢鏈嶅姟娑堣垂鏂广€傚湪寰湇鍔℃灦鏋勪腑锛屼笟鍔$郴缁熼€氬父瑕佷緷璧栧涓湇鍔★紝渚濊禆鐨勬煇涓湇鍔′笉鍙敤灏嗕細褰卞搷涓氬姟绯荤粺鐨勫彲鐢ㄦ€с€傝В鍐宠繖涓棶棰樼殑鏂规硶鏄強鏃跺彂鐜版湇鍔$殑鈥滀笉鍙敤鈥濈姸鎬侊紝鍦ㄨ皟鐢ㄦ椂蹇€熷け璐ヨ€屼笉鏄瓑寰呰皟鍔ㄨ秴鏃舵垨鑰呴噸璇曘€係entinel 閫氳繃鐔旀柇闄嶇骇鏉ヨ揪鍒板揩閫熷け璐ョ殑鐩殑銆傞€氳繃鈥滈檷绾ц鍒欌€濋〉闈㈠彲浠ユ煡鐪嬪拰閰嶇疆闄嶇骇瑙勫垯銆? +降级规则用于保护服务消费方。在微服务架构中,业务系统通常要依赖多个服务,依赖的某个服务不可用将会影响业务系统的可用性。解决这个问题的方法是及时发现服务的“不可用”状态,在调用时快速失败而不是等待调动超时或者重试。Sentinel 通过熔断降级来达到快速失败的目的。通过“降级规则”页面可以查看和配置降级规则。 -#### 1.4.3 绯荤粺淇濇姢瑙勫垯 +#### 1.4.3 系统保护规则 -绯荤粺淇濇姢瑙勫垯锛堢畝绉癭绯荤粺瑙勫垯`锛夌敤浜庝繚鎶ゆ暣涓郴缁熸寚鏍囧浜庡畨鍏ㄦ按浣嶃€傛棤璁烘槸鏈嶅姟鎻愪緵鏂硅繕鏄秷璐规柟锛屾椿璺冪嚎绋嬫暟杩囧銆佺郴缁烲OAD绛夎繃楂橀兘鏄郴缁熷浜庨珮姘翠綅鐨勬寚鏍囥€傚綋绯荤粺姘翠綅杩囬珮鏃讹紝绯荤粺搴旀嫆缁濆澶栨彁渚涙湇鍔′互渚胯繀閫熼檷浣庤祫婧愬崰鐢ㄣ€傞€氳繃鈥滅郴缁熻鍒欌€濋〉闈㈠彲浠ユ煡鐪嬪拰璁剧疆绯荤粺淇濇姢瑙勫垯銆? +系统保护规则(简称`系统规则`)用于保护整个系统指标处于安全水位。无论是服务提供方还是消费方,活跃线程数过多、系统LOAD等过高都是系统处于高水位的指标。当系统水位过高时,系统应拒绝对外提供服务以便迅速降低资源占用。通过“系统规则”页面可以查看和设置系统保护规则。 -## 2. 闄愬埗 +## 2. 限制 -鏈帶鍒跺彴鍙槸鐢ㄤ簬婕旂ず Sentinel 鐨勫熀鏈兘鍔涘拰宸ヤ綔娴佺▼锛屽苟娌℃湁渚濊禆鐢熶骇鐜涓墍蹇呴渶鐨勭粍浠讹紝姣斿**鎸佷箙鍖栫殑鍚庣鏁版嵁搴撱€佸彲闈犵殑閰嶇疆涓績**绛夈€? -鐩墠 Sentinel 閲囩敤鍐呭瓨鎬佺殑鏂瑰紡瀛樺偍鐩戞帶鍜岃鍒欐暟鎹紝鐩戞帶鏈€闀垮瓨鍌ㄦ椂闂翠负 5 鍒嗛挓锛屾帶鍒跺彴閲嶅惎鍚庢暟鎹涪澶便€? +本控制台只是用于演示 Sentinel 的基本能力和工作流程,并没有依赖生产环境中所必需的组件,比如**持久化的后端数据库、可靠的配置中心**等。 +目前 Sentinel 采用内存态的方式存储监控和规则数据,监控最长存储时间为 5 分钟,控制台重启后数据丢失。 -## 3. 閰嶇疆椤? +## 3. 配置项 -鎺у埗鍙扮殑涓€浜涚壒鎬у彲浠ラ€氳繃閰嶇疆椤规潵杩涜閰嶇疆锛岄厤缃」涓昏鏈変袱涓潵婧愶細`System.getProperty()` 鍜?`System.getenv()`锛屽悓鏃跺瓨鍦ㄦ椂鍚庤€呭彲浠ヨ鐩栧墠鑰呫€? +控制台的一些特性可以通过配置项来进行配置,配置项主要有两个来源:`System.getProperty()` 和 `System.getenv()`,同时存在时后者可以覆盖前者。 -> 閫氳繃鐜鍙橀噺杩涜閰嶇疆鏃讹紝鍥犱负涓嶆敮鎸?`.` 鎵€浠ラ渶瑕佸皢鍏舵洿鎹负 `_`銆? +> 通过环境变量进行配置时,因为不支持 `.` 所以需要将其更换为 `_`。 -椤?|绫诲瀷|榛樿鍊?|鏈€灏忓€?| 鎻忚堪 ---- |---|---|---| --- -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|距离最近心跳时间超过指定时间是否自动删除失联节点,默认关闭 -閰嶇疆绀轰緥锛? +配置示例: -- 鍛戒护琛屾柟寮忥細 +- 命令行方式: ```shell java -Dsentinel.dashboard.app.hideAppNoMachineMillis=60000 ``` -- Java 鏂瑰紡锛? +- Java 方式: ```java System.setProperty("sentinel.dashboard.app.hideAppNoMachineMillis", "60000"); ``` -- 鐜鍙橀噺鏂瑰紡锛? +- 环境变量方式: ```shell sentinel_dashboard_app_hideAppNoMachineMillis=60000 ``` -鏇村锛? +更多: -- [Sentinel 鎺у埗鍙板惎鍔ㄥ拰瀹㈡埛绔帴鍏(./README.md) -- [鎺у埗鍙?Wiki](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0) +- [Sentinel 控制台启动和客户端接入](./README.md) +- [控制台 Wiki](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0) diff --git a/sentinel-demo/sentinel-demo-dubbo/README.md b/sentinel-demo/sentinel-demo-dubbo/README.md index 29e7f71770..8826fa76d8 100644 --- a/sentinel-demo/sentinel-demo-dubbo/README.md +++ b/sentinel-demo/sentinel-demo-dubbo/README.md @@ -1,6 +1,6 @@ -# Sentinel Dubbo Demo +# Sentinel Dubbo Demo -Sentinel 鎻愪緵浜嗕笌 Dubbo 鏁村悎鐨勬ā鍧?- Sentinel Dubbo Adapter锛屼富瑕佸寘鎷拡瀵?Service Provider 鍜?Service Consumer 瀹炵幇鐨?Filter銆備娇鐢ㄦ椂鐢ㄦ埛鍙渶寮曞叆浠ヤ笅妯″潡锛堜互 Maven 涓轰緥锛夛細 +Sentinel 提供了与 Dubbo 整合的模块 - Sentinel Dubbo Adapter,主要包括针对 Service Provider 和 Service Consumer 实现的 Filter。使用时用户只需引入以下模块(以 Maven 为例): ```xml @@ -10,11 +10,11 @@ Sentinel 鎻愪緵浜嗕笌 Dubbo 鏁村悎鐨勬ā鍧?- Sentinel Dubbo Adapter ``` -寮曞叆姝や緷璧栧悗锛孌ubbo 鐨勬湇鍔℃帴鍙e拰鏂规硶锛堝寘鎷皟鐢ㄧ鍜屾湇鍔$锛夊氨浼氭垚涓?Sentinel 涓殑璧勬簮锛屽湪閰嶇疆浜嗚鍒欏悗灏卞彲浠ヨ嚜鍔ㄤ韩鍙楀埌 Sentinel 鐨勯槻鎶よ兘鍔涖€? +引入此依赖后,Dubbo 的服务接口和方法(包括调用端和服务端)就会成为 Sentinel 中的资源,在配置了规则后就可以自动享受到 Sentinel 的防护能力。 -> **娉細鑻ュ笇鏈涙帴鍏?Dashboard锛岃鍙傝€冨悗闈㈡帴鍏ユ帶鍒跺彴鐨勬楠ゃ€傚彧寮曞叆 Sentinel Dubbo Adapter 鏃犳硶鎺ュ叆鎺у埗鍙帮紒** +> **注:若希望接入 Dashboard,请参考后面接入控制台的步骤。只引入 Sentinel Dubbo Adapter 无法接入控制台!** -鑻ヤ笉甯屾湜寮€鍚?Sentinel Dubbo Adapter 涓殑鏌愪釜 Filter锛屽彲浠ユ墜鍔ㄥ叧闂搴旂殑 Filter锛屾瘮濡傦細 +若不希望开启 Sentinel Dubbo Adapter 中的某个 Filter,可以手动关闭对应的 Filter,比如: ```java @Bean @@ -25,88 +25,88 @@ public ConsumerConfig consumerConfig() { } ``` -鎴戜滑鎻愪緵浜嗗嚑涓叿浣撶殑 Demo 鏉ュ垎鍒紨绀?Provider 鍜?Consumer 鐨勯檺娴佸満鏅€? +我们提供了几个具体的 Demo 来分别演示 Provider 和 Consumer 的限流场景。 ## Service Provider -Service Provider 鐢ㄤ簬鍚戝鐣屾彁渚涙湇鍔★紝澶勭悊鍚勪釜娑堣垂鑰呯殑璋冪敤璇锋眰銆備负浜嗕繚鎶?Provider 涓嶈婵€澧炵殑娴侀噺鎷栧灝褰卞搷绋冲畾鎬э紝鍙互缁?Provider 閰嶇疆 **QPS 妯″紡**鐨勯檺娴侊紝杩欐牱褰撴瘡绉掔殑璇锋眰閲忚秴杩囪瀹氱殑闃堝€兼椂浼氳嚜鍔ㄦ嫆缁濆鐨勮姹傘€傞檺娴佺矑搴﹀彲浠ユ槸鏈嶅姟鎺ュ彛鍜屾湇鍔℃柟娉曚袱绉嶇矑搴︺€傝嫢甯屾湜鏁翠釜鏈嶅姟鎺ュ彛鐨?QPS 涓嶈秴杩囦竴瀹氭暟鍊硷紝鍒欏彲浠ヤ负瀵瑰簲鏈嶅姟鎺ュ彛璧勬簮锛坮esourceName 涓?*鎺ュ彛鍏ㄩ檺瀹氬悕**锛夐厤缃?QPS 闃堝€硷紱鑻ュ笇鏈涙湇鍔$殑鏌愪釜鏂规硶鐨?QPS 涓嶈秴杩囦竴瀹氭暟鍊硷紝鍒欏彲浠ヤ负瀵瑰簲鏈嶅姟鏂规硶璧勬簮锛坮esourceName 涓?*鎺ュ彛鍏ㄩ檺瀹氬悕:鏂规硶绛惧悕**锛夐厤缃?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)`锛孭rovider 绔鏂规硶璁惧畾 QPS 闃堝€间负 10銆傚湪 Consumer 绔湪 1s 涔嬪唴杩炵画鍙戣捣 15 娆¤皟鐢紝鍙互閫氳繃鏃ュ織鏂囦欢鐪嬪埌 Provider 绔闄愭祦銆傛嫤鎴棩蹇楃粺涓€璁板綍鍦?`~/logs/csp/sentinel-block.log` 涓細 +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` 中: ```plaintext 2018-07-24 17:13:43|1|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String),FlowException,default,|5,0 ``` -鍦?Provider 瀵瑰簲鐨?metrics 鏃ュ織涓篃鏈夎褰曪細 +在 Provider 对应的 metrics 日志中也有记录: ```plaintext 1532423623000|2018-07-24 17:13:43|com.alibaba.csp.sentinel.demo.dubbo.FooService|15|0|15|0|3 1532423623000|2018-07-24 17:13:43|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String)|10|5|10|0|0 ``` -寰堝鍦烘櫙涓嬶紝鏍规嵁**璋冪敤鏂?*鏉ラ檺娴佷篃鏄潪甯搁噸瑕佺殑銆傛瘮濡傛湁涓や釜鏈嶅姟 A 鍜?B 閮藉悜 Service Provider 鍙戣捣璋冪敤璇锋眰锛屾垜浠笇鏈涘彧瀵规潵鑷湇鍔?B 鐨勮姹傝繘琛岄檺娴侊紝鍒欏彲浠ヨ缃檺娴佽鍒欑殑 `limitApp` 涓烘湇鍔?B 鐨勫悕绉般€係entinel Dubbo Adapter 浼氳嚜鍔ㄨВ鏋?Dubbo 娑堣垂鑰咃紙璋冪敤鏂癸級鐨?application name 浣滀负璋冪敤鏂瑰悕绉帮紙`origin`锛夛紝鍦ㄨ繘琛岃祫婧愪繚鎶ょ殑鏃跺€欓兘浼氬甫涓婅皟鐢ㄦ柟鍚嶇О銆傝嫢闄愭祦瑙勫垯鏈厤缃皟鐢ㄦ柟锛坄default`锛夛紝鍒欒闄愭祦瑙勫垯瀵规墍鏈夎皟鐢ㄦ柟鐢熸晥銆傝嫢闄愭祦瑙勫垯閰嶇疆浜嗚皟鐢ㄦ柟鍒欓檺娴佽鍒欏皢浠呭鎸囧畾璋冪敤鏂圭敓鏁堛€? +很多场景下,根据**调用方**来限流也是非常重要的。比如有两个服务 A 和 B 都向 Service Provider 发起调用请求,我们希望只对来自服务 B 的请求进行限流,则可以设置限流规则的 `limitApp` 为服务 B 的名称。Sentinel Dubbo Adapter 会自动解析 Dubbo 消费者(调用方)的 application name 作为调用方名称(`origin`),在进行资源保护的时候都会带上调用方名称。若限流规则未配置调用方(`default`),则该限流规则对所有调用方生效。若限流规则配置了调用方则限流规则将仅对指定调用方生效。 -> 娉細Dubbo 榛樿閫氫俊涓嶆惡甯﹀绔?application name 淇℃伅锛屽洜姝ら渶瑕佸紑鍙戣€呭湪璋冪敤绔墜鍔ㄥ皢 application name 缃叆 attachment 涓紝provider 绔繘琛岀浉搴旂殑瑙f瀽銆係entinel Dubbo Adapter 瀹炵幇浜嗕竴涓?Filter 鐢ㄤ簬鑷姩浠?consumer 绔悜 provider 绔€忎紶 application name銆傝嫢璋冪敤绔湭寮曞叆 Sentinel Dubbo Adapter锛屽張甯屾湜鏍规嵁璋冪敤绔檺娴侊紝鍙互鍦ㄨ皟鐢ㄧ鎵嬪姩灏?application name 缃叆 attachment 涓紝key 涓?`dubboApplication`銆? +> 注:Dubbo 默认通信不携带对端 application name 信息,因此需要开发者在调用端手动将 application name 置入 attachment 中,provider 端进行相应的解析。Sentinel Dubbo Adapter 实现了一个 Filter 用于自动从 consumer 端向 provider 端透传 application name。若调用端未引入 Sentinel Dubbo Adapter,又希望根据调用端限流,可以在调用端手动将 application name 置入 attachment 中,key 为 `dubboApplication`。 -鍦ㄩ檺娴佹棩蹇椾腑浼氫篃浼氳褰曡皟鐢ㄦ柟鐨勫悕绉帮紝濡傦細 +在限流日志中会也会记录调用方的名称,如: ```plaintext 2018-07-25 16:26:48|1|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String),FlowException,default,demo-consumer|5,0 ``` -鍏朵腑鏃ュ織涓殑 `demo-consumer` 鍗充负璋冪敤鏂瑰悕绉般€? +其中日志中的 `demo-consumer` 即为调用方名称。 ## Service Consumer -> 瀵规湇鍔℃秷璐规柟鐨勬祦閲忔帶鍒跺彲鍒嗕负**鎺у埗骞跺彂绾跨▼鏁?*鍜?*鏈嶅姟闄嶇骇**涓や釜缁村害銆? +> 对服务消费方的流量控制可分为**控制并发线程数**和**服务降级**两个维度。 -### 骞跺彂绾跨▼鏁伴檺娴? +### 并发线程数限流 -Service Consumer 浣滀负瀹㈡埛绔幓璋冪敤杩滅▼鏈嶅姟銆傛瘡涓€涓湇鍔¢兘鍙兘浼氫緷璧栧嚑涓笅娓告湇鍔★紝鑻ユ煇涓湇鍔?A 渚濊禆鐨勪笅娓告湇鍔?B 鍑虹幇浜嗕笉绋冲畾鐨勬儏鍐碉紝鏈嶅姟 A 璇锋眰鏈嶅姟 B 鐨勫搷搴旀椂闂村彉闀匡紝浠庤€屾湇鍔?A 璋冪敤鏈嶅姟 B 鐨勭嚎绋嬪氨浼氫骇鐢熷爢绉紝鏈€缁堝彲鑳借€楀敖鏈嶅姟 A 鐨勭嚎绋嬫暟銆傛垜浠€氳繃鐢ㄥ苟鍙戠嚎绋嬫暟鏉ユ帶鍒跺涓嬫父鏈嶅姟 B 鐨勮闂紝鏉ヤ繚璇佷笅娓告湇鍔′笉鍙潬鐨勬椂鍊欙紝涓嶄細鎷栧灝鏈嶅姟鑷韩銆傚熀浜庤繖绉嶅満鏅紝鎺ㄨ崘缁?Consumer 閰嶇疆**绾跨▼鏁版ā寮?*鐨勯檺娴侊紝鏉ヤ繚璇佽嚜韬笉琚笉绋冲畾鏈嶅姟鎵€褰卞搷銆傞檺娴佺矑搴﹀悓鏍峰彲浠ユ槸鏈嶅姟鎺ュ彛鍜屾湇鍔℃柟娉曚袱绉嶇矑搴︺€? +Service Consumer 作为客户端去调用远程服务。每一个服务都可能会依赖几个下游服务,若某个服务 A 依赖的下游服务 B 出现了不稳定的情况,服务 A 请求服务 B 的响应时间变长,从而服务 A 调用服务 B 的线程就会产生堆积,最终可能耗尽服务 A 的线程数。我们通过用并发线程数来控制对下游服务 B 的访问,来保证下游服务不可靠的时候,不会拖垮服务自身。基于这种场景,推荐给 Consumer 配置**线程数模式**的限流,来保证自身不被不稳定服务所影响。限流粒度同样可以是服务接口和服务方法两种粒度。 -閲囩敤鍩轰簬绾跨▼鏁扮殑闄愭祦妯″紡鍚庯紝鎴戜滑涓嶉渶瑕佸啀鏄惧紡鍦板幓杩涜绾跨▼姹犻殧绂伙紝Sentinel 浼氭帶鍒惰祫婧愮殑绾跨▼鏁帮紝瓒呭嚭鐨勮姹傜洿鎺ユ嫆缁濓紝鐩村埌鍫嗙Н鐨勭嚎绋嬪鐞嗗畬鎴愩€? +采用基于线程数的限流模式后,我们不需要再显式地去进行线程池隔离,Sentinel 会控制资源的线程数,超出的请求直接拒绝,直到堆积的线程处理完成。 -Demo 2 婕旂ず浜嗘闄愭祦鍦烘櫙锛屾垜浠湅涓€涓嬭繖绉嶆ā寮忕殑鏁堟灉銆傚亣璁惧綋鍓嶆湇鍔?A 渚濊禆涓や釜杩滅▼鏈嶅姟鏂规硶 `sayHello(java.lang.String)` 鍜?`doAnother()`銆傚墠鑰呰繙绋嬭皟鐢ㄧ殑鍝嶅簲鏃堕棿 涓?1s-1.5s涔嬮棿锛屽悗鑰?RT 闈炲父灏忥紙30 ms 宸﹀彸锛夈€傛湇鍔?A 绔涓や釜杩滅▼鏂规硶 thread count 涓?5銆傜劧鍚庢瘡闅?50 ms 宸﹀彸鍚戠嚎绋嬫睜鎶曞叆涓や釜浠诲姟锛屼綔涓烘秷璐硅€呭垎鍒繙绋嬭皟鐢ㄥ搴旀柟娉曪紝鎸佺画 10 娆°€傚彲浠ョ湅鍒?`sayHello` 鏂规硶琚檺娴?5 娆★紝鍥犱负鍚庨潰璋冪敤鐨勬椂鍊欏墠闈㈢殑杩滅▼璋冪敤杩樻湭杩斿洖锛圧T 楂橈級锛涜€?`doAnother()` 璋冪敤鍒欎笉鍙楀奖鍝嶃€傜嚎绋嬫暟鐩秴鍑烘椂蹇€熷け璐ヨ兘澶熸湁鏁堝湴闃叉鑷繁琚參璋冪敤鎵€褰卞搷銆? +Demo 2 演示了此限流场景,我们看一下这种模式的效果。假设当前服务 A 依赖两个远程服务方法 `sayHello(java.lang.String)` 和 `doAnother()`。前者远程调用的响应时间 为 1s-1.5s之间,后者 RT 非常小(30 ms 左右)。服务 A 端设两个远程方法 thread count 为 5。然后每隔 50 ms 左右向线程池投入两个任务,作为消费者分别远程调用对应方法,持续 10 次。可以看到 `sayHello` 方法被限流 5 次,因为后面调用的时候前面的远程调用还未返回(RT 高);而 `doAnother()` 调用则不受影响。线程数目超出时快速失败能够有效地防止自己被慢调用所影响。 -### 鏈嶅姟闄嶇骇 +### 服务降级 -褰撴湇鍔′緷璧栦簬澶氫釜涓嬫父鏈嶅姟锛岃€屾煇涓笅娓告湇鍔¤皟鐢ㄩ潪甯告參鏃讹紝浼氫弗閲嶅奖鍝嶅綋鍓嶆湇鍔$殑璋冪敤銆傝繖閲屾垜浠彲浠ュ埄鐢?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 的[降级规则]()。这样当调用链路中某个服务调用的平均 RT 升高,在一定的次数内超过配置的 RT 阈值,Sentinel 就会对此调用资源进行降级操作,接下来的调用都会立刻拒绝,直到过了一段设定的时间后才恢复,从而保护服务不被调用端短板所影响。同时可以配合 fallback 功能使用,在被降级的时候提供相应的处理逻辑。 ## Fallback -浠?0.1.1 鐗堟湰寮€濮嬶紝Sentinel Dubbo Adapter 杩樻敮鎸侀厤缃叏灞€鐨?fallback 鍑芥暟锛屽彲浠ュ湪 Dubbo 鏈嶅姟琚檺娴?闄嶇骇/璐熻浇淇濇姢鐨勬椂鍊欒繘琛岀浉搴旂殑 fallback 澶勭悊銆傜敤鎴峰彧闇€瑕佸疄鐜拌嚜瀹氫箟鐨?[`DubboFallback`](https://github.com/alibaba/Sentinel/blob/master/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallback.java) 鎺ュ彛锛屽苟閫氳繃 `DubboFallbackRegistry` 娉ㄥ唽鍗冲彲銆傞粯璁ゆ儏鍐典細鐩存帴灏?`BlockException` 鍖呰鍚庢姏鍑恒€傚悓鏃讹紝鎴戜滑杩樺彲浠ラ厤鍚?[Dubbo 鐨?fallback 鏈哄埗](http://dubbo.apache.org/#!/docs/user/demos/local-mock.md?lang=zh-cn) 鏉ヤ负闄嶇骇鐨勬湇鍔℃彁渚涙浛浠g殑瀹炵幇銆? +从 0.1.1 版本开始,Sentinel Dubbo Adapter 还支持配置全局的 fallback 函数,可以在 Dubbo 服务被限流/降级/负载保护的时候进行相应的 fallback 处理。用户只需要实现自定义的 [`DubboFallback`](https://github.com/alibaba/Sentinel/blob/master/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallback.java) 接口,并通过 `DubboFallbackRegistry` 注册即可。默认情况会直接将 `BlockException` 包装后抛出。同时,我们还可以配合 [Dubbo 的 fallback 机制](http://dubbo.apache.org/#!/docs/user/demos/local-mock.md?lang=zh-cn) 来为降级的服务提供替代的实现。 -Demo 2 鐨?Consumer 绔彁渚涗簡涓€涓畝鍗曠殑 fallback 绀轰緥銆? +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 杩樻彁渚涗簡涓€涓帶鍒跺彴锛圖ashboard锛夌敤浜庨厤缃鍒欍€佹煡鐪嬬洃鎺с€佹満鍣ㄥ彂鐜扮瓑鍔熻兘銆? +Sentinel 还提供 API 用于获取实时的监控信息,对应文档见[此处]()。为了便于使用,Sentinel 还提供了一个控制台(Dashboard)用于配置规则、查看监控、机器发现等功能。 -鎺ュ叆 Dashboard 鐨勬楠わ紙**缂轰竴涓嶅彲**锛夛細 +接入 Dashboard 的步骤(**缺一不可**): -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锛岀敤浜庝笂鎶ョ浉鍏充俊鎭? - - `-Dcsp.sentinel.dashboard.server`锛氭帶鍒跺彴鐨勫湴鍧€ - - `-Dproject.name`锛氬簲鐢ㄥ悕绉帮紝浼氬湪鎺у埗鍙颁腑鏄剧ず +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,用于上报相关信息 + - `-Dcsp.sentinel.dashboard.server`:控制台的地址 + - `-Dproject.name`:应用名称,会在控制台中显示 -娉ㄦ剰鏌愪簺鐜涓嬫湰鍦拌繍琛?Dubbo 鏈嶅姟杩橀渶瑕佸姞涓?`-Djava.net.preferIPv4Stack=true` 鍙傛暟銆傛瘮濡?Service Provider 绀轰緥鐨勫惎鍔ㄥ弬鏁帮細 +注意某些环境下本地运行 Dubbo 服务还需要加上 `-Djava.net.preferIPv4Stack=true` 参数。比如 Service Provider 示例的启动参数: ```bash -Djava.net.preferIPv4Stack=true -Dcsp.sentinel.api.port=8720 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=dubbo-provider-demo ``` -Service Consumer 绀轰緥鐨勫惎鍔ㄥ弬鏁帮細 +Service Consumer 示例的启动参数: ```bash -Djava.net.preferIPv4Stack=true -Dcsp.sentinel.api.port=8721 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=dubbo-consumer-demo ``` -杩欐牱鍦ㄥ惎鍔?Service Provider 鍜?Service Consumer 绀轰緥浠ュ悗锛屽氨鍙互鍦?Sentinel 鎺у埗鍙颁腑鎵惧埌鎴戜滑鐨勬湇鍔′簡銆傚彲浠ュ緢鏂逛究鍦板湪鎺у埗鍙颁腑閰嶇疆闄愭祦瑙勫垯锛? +这样在启动 Service Provider 和 Service Consumer 示例以后,就可以在 Sentinel 控制台中找到我们的服务了。可以很方便地在控制台中配置限流规则: -![瑙勫垯閰嶇疆](http://dubbo.incubator.apache.org/img/blog/sentinel-dashboard-view-rules.png) +![规则配置](http://dubbo.incubator.apache.org/img/blog/sentinel-dashboard-view-rules.png) -鎴栬€呮煡鐪嬪疄鏃剁洃鎺ф暟鎹細 +或者查看实时监控数据: -![绉掔骇瀹炴椂鐩戞帶](http://dubbo.incubator.apache.org/img/blog/sentinel-dashboard-metrics.png) +![秒级实时监控](http://dubbo.incubator.apache.org/img/blog/sentinel-dashboard-metrics.png) From d1ff670999b567ae569a4692b6f88c1120019b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=B0=A7?= Date: Tue, 16 Dec 2025 16:57:57 +0800 Subject: [PATCH 8/9] fix: wrap remaining bare URLs with angle brackets (MD034) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix bare URL in Sentinel_Dashboard_Feature.md (控制台 Wiki link) - Fix bare URLs in sentinel-demo-dubbo README (流量控制, 控制台文档) All markdownlint MD034 errors now resolved --- sentinel-dashboard/Sentinel_Dashboard_Feature.md | 2 +- sentinel-demo/sentinel-demo-dubbo/README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sentinel-dashboard/Sentinel_Dashboard_Feature.md b/sentinel-dashboard/Sentinel_Dashboard_Feature.md index 4fe4867970..036dff0873 100755 --- a/sentinel-dashboard/Sentinel_Dashboard_Feature.md +++ b/sentinel-dashboard/Sentinel_Dashboard_Feature.md @@ -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]() diff --git a/sentinel-demo/sentinel-demo-dubbo/README.md b/sentinel-demo/sentinel-demo-dubbo/README.md index 8826fa76d8..083a659463 100644 --- a/sentinel-demo/sentinel-demo-dubbo/README.md +++ b/sentinel-demo/sentinel-demo-dubbo/README.md @@ -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]()。 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` 中: @@ -84,7 +84,7 @@ Sentinel 还提供 API 用于获取实时的监控信息,对应文档见[此 接入 Dashboard 的步骤(**缺一不可**): -1. 按照 [Sentinel 控制台文档](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0) 启动控制台 +1. 按照 [Sentinel 控制台文档]() 启动控制台 2. 应用引入 `sentinel-transport-simple-http` 依赖,以便控制台可以拉取对应应用的相关信息 3. 给应用添加相关的启动参数,启动应用。需要配置的参数有: - `-Dcsp.sentinel.api.port`:客户端的 port,用于上报相关信息 From 5485e2284507e19a97550e3c7aee4a354d831f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=B0=A7?= Date: Tue, 16 Dec 2025 22:19:31 +0800 Subject: [PATCH 9/9] fix: remove trailing spaces from table rows (MD009) - Fix trailing spaces in sentinel-adapter/sentinel-spring-webmvc-adapter/README.md - Fix trailing spaces in sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md - Fix trailing spaces in sentinel-dashboard/README.md All MD009 errors now resolved --- .../sentinel-spring-webmvc-adapter/README.md | 28 +++++++++---------- .../README.md | 10 +++---- sentinel-dashboard/README.md | 8 +++--- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md b/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md index 59e90f814c..a888d0f46f 100755 --- a/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md +++ b/sentinel-adapter/sentinel-spring-webmvc-adapter/README.md @@ -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` | diff --git a/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md b/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md index 0acfde911a..47e2000a7b 100644 --- a/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md +++ b/sentinel-cluster/sentinel-cluster-server-envoy-rls/README.md @@ -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 diff --git a/sentinel-dashboard/README.md b/sentinel-dashboard/README.md index 22ed623838..0ba94fe4ab 100755 --- a/sentinel-dashboard/README.md +++ b/sentinel-dashboard/README.md @@ -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)。