You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by hu...@apache.org on 2018/07/27 07:47:38 UTC

[incubator-dubbo-website] branch asf-site updated: Add English version for Sentinel blog and update CN version (#61)

This is an automated email from the ASF dual-hosted git repository.

huxing pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 4fffc6d  Add English version for Sentinel blog and update CN version (#61)
4fffc6d is described below

commit 4fffc6dd925c57e9794b6ef3d866983d7eaed30d
Author: Eric Zhao <sc...@gmail.com>
AuthorDate: Fri Jul 27 15:47:36 2018 +0800

    Add English version for Sentinel blog and update CN version (#61)
    
    Signed-off-by: Eric Zhao <sc...@gmail.com>
---
 blog/en-us/sentinel-introduction-for-dubbo.md | 104 ++++++++++++++++++++++++++
 blog/zh-cn/sentinel-introduction-for-dubbo.md |  16 +++-
 md_json/blog.json                             |   6 +-
 site_config/blog.js                           |   7 ++
 4 files changed, 130 insertions(+), 3 deletions(-)

diff --git a/blog/en-us/sentinel-introduction-for-dubbo.md b/blog/en-us/sentinel-introduction-for-dubbo.md
new file mode 100644
index 0000000..de91f8d
--- /dev/null
+++ b/blog/en-us/sentinel-introduction-for-dubbo.md
@@ -0,0 +1,104 @@
+# Sentinel: The flow sentinel of Dubbo services
+
+In large clusters there may be thousands of Dubbo service instances in production, with continuous traffic coming in. However, in distributed systems, some services may be unavailable due to various of failure such as traffic surge, high system load, and network latency. If no control actions are performed, this may cause cascading failure, affecting the availability of the service. So we need a powerful library - Sentinel, which can guarantee the stability of the service, to protect the [...]
+
+## Introduction to Sentinel
+
+[Sentinel](https://github.com/alibaba/Sentinel) is a powerful library opensourced by Alibaba Middleware Team. Sentinel takes "**flow**" as the breakthrough point, and covers multiple fields including flow control, concurrency, circuit breaking and load protection to protect service stability.
+
+There are mainly three features in Sentinel:
+
+- **Flow Control**: Sentinel can control the traffic flow of resource calls based on different runtime metrics (such as QPS, number of threads, system load, etc.), for different invocation paths, and adjust random traffic to appropriate shapes (e.g. uniform speed).
+- **Circuit Breaking**: When a resource in the invocation chain is unstable (average RT increase or exception ratio increase), Sentinel will fast-fail the call request for this resource to avoid affecting other resources, causing cascade failure.
+- **System Load Protection**: Sentinel can be used to protect your server in case the system load goes too high. It helps you to achieve a good balance between system load and incoming requests.
+
+The commonly used circuit breaker/isolation library in production is [Netflix Hystrix](https://github.com/Netflix/Hystrix). Hystrix focuses on the concept of isolation, which isolates dependencies (that is resource in Sentinel) through thread pools or semaphores. The benefit of Hystrix thread pool isolation is that the isolation is thorough, but the downside is that you have to create a lot of thread pools, pre-divide dependencies, and allocate thread pools to each dependency. Sentinel p [...]
+
+Hystrix uses Circuit Breaker Pattern to automatically fast-fail the service when exception ratio exceeds the threshold. Sentinel's circuit breaking feature is more versatile, which supports two metrics: average response time and failure ratio. Sentinel also provides various invocation chain path and flow control effects support, as well as the ability to adjust the traffic in real time according to the system load to protect the system. At the same time, Sentinel also provides a real-tim [...]
+
+## Best Practice for using Dubbo with Sentinel
+
+[Sentinel Dubbo Adapter](https://github.com/dubbo/dubbo-sentinel-support) provides service consumer filter and provider filter for Dubbo services. We can add the following dependency in `pom.xml` (if you are using Maven):
+
+```xml
+<dependency>
+    <groupId>com.alibaba.csp</groupId>
+    <artifactId>sentinel-dubbo-adapter</artifactId>
+    <version>x.y.z</version>
+</dependency>
+```
+
+The two filters are enabled by default. Once you add the dependency, the Dubbo services and methods will become protected resources in Sentinel, which can leverage Sentinel's flow control and guard ability when rules are configured. If you don't want to enable the filter, you can manually disable it. For example:
+
+```java
+@Bean
+public ConsumerConfig consumerConfig() {
+    ConsumerConfig consumerConfig = new ConsumerConfig();
+    consumerConfig.setFilter("-sentinel.dubbo.consumer.filter");
+    return consumerConfig;
+}
+```
+
+We've provided sereval demos, you can check here: [sentinel-demo-dubbo](https://github.com/alibaba/Sentinel/tree/master/sentinel-demo/sentinel-demo-dubbo)。
+
+### Service Provider
+
+Dubbo service providers provide services for outside world and handle requests from consumers. To protect the service provider from suffering the proliferation of traffic flow, you can set flow rules in **QPS mode** to the service provider. Thus, when the number of requests per second exceeds the threshold, new requests are automatically rejected.
+
+The flow control for Dubbo services has two granularities: service interface and service method.
+
+- Service interface:resourceName format is `interfaceName`,e.g. `com.alibaba.csp.sentinel.demo.dubbo.FooService`
+- Service method:resourceName format is `interfaceName:methodSignature`,e.g. `com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String)`
+
+For the detail of flow rule configuration and flow control, please refer to [Flow Control | Sentinel](https://github.com/alibaba/Sentinel/wiki/Flow-Control).
+
+Let's take a look at the effect of the QPS flow control. Assume that we have a service interface `com.alibaba.csp.sentinel.demo.dubbo.FooService`, which contains a method `sayHello(java.lang.String)`. We set flow rule for service provider (QPS count = 10). Then we do RPC 15 times at service consumer continuously in 1s. We can see the blocked metrics in the log. The log of blocked calls is located in `~/logs/csp/sentinel-block.log`:
+
+```
+2018-07-24 17:13:43|1|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String),FlowException,default,|5,0
+```
+
+Log messages will also appear in provider's metric log:
+
+```
+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
+```
+
+In many circumstances, it's also significant to control traffic flow based on the **caller**. For example, assuming that there are two services A and B, both of them initiate remote call requests to the service provider. If we want to limit the calls from service B only, we can set the `limitApp` of flow rule as the identifier of service B (e.g. service name). The Sentinel Dubbo Adapter will automatically resolve the Dubbo consumer's *application name* as the caller's name (`origin`), an [...]
+
+> Note: Dubbo consumer does not provide its Dubbo application name when doing RPC, so developers should manually put the application name into *attachment* at consumer side, then extract it at provider side. Sentinel Dubbo Adapter has implemented a filter where consumer can carry application name information to provider automatically. If the counsmer does not use Sentinel Dubbo Adapter but requires flow control based on caller, developers can manually put the application name into attach [...]
+
+The `sentinel-block.log` will also record caller name. For example:
+
+```
+2018-07-25 16:26:48|1|com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String),FlowException,default,demo-consumer|5,0
+```
+
+The `demo-consumer` in the log is the caller name (origin).
+
+### Service Consumer
+
+Dubbo service consumers act as a client to invoke the remote service. Each service may depend on several downstream services. If a service A depends on the downstream service B, and service B is unstable (i.e. the response time becomes longer), the number of threads where service A invokes service B will accumulate, thus may eventually run out of service A's thread pool. We use the thread count to control access to downstream service B. This can ensure service itself not affected by othe [...]
+
+The thread-count-based flow control mode does not require us to explicitly perform thread pool isolation. Sentinel will control the number of threads of the resource, and the excess requests will be rejected directly until the stacked tasks are completed.
+
+### Sentinel Dashboard
+
+For ease of use, Sentinel provides a Dashboard for configuring rules, viewing monitoring metrics, machine discovery, and more. We only need to start the dashborad according to the [Sentinel dashboard documentation](https://github.com/alibaba/Sentinel/wiki/Dashboard), then add the appropriate parameters to the corresponding application and launch it. For example, the startup parameters of the service provider demo in this article is:
+
+```bash
+-Djava.net.preferIPv4Stack=true -Dcsp.sentinel.api.port=8720 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=dubbo-provider-demo
+```
+
+After launching the service provider demo, we can find our application in the Sentinel dashboard. It's convenient to configure the rules in the dashboard:
+
+![Rule List](../../img/blog/sentinel-dashboard-view-rules.png)
+
+Or view real-time metrics:
+
+![Real-time metrics monitoring](../../img/blog/sentinel-dashboard-metrics.png)
+
+## Summary
+
+This blog post only introduces the simplest scenario in Sentinel - Traffic Flow Control. Sentinel can handle more complex scenarios like circuit breaking, cold starting and uniform traffic flow. For more scenarios, you can dig into [Sentinel Wiki](https://github.com/alibaba/Sentinel/wiki).
diff --git a/blog/zh-cn/sentinel-introduction-for-dubbo.md b/blog/zh-cn/sentinel-introduction-for-dubbo.md
index 280f95a..bd96178 100644
--- a/blog/zh-cn/sentinel-introduction-for-dubbo.md
+++ b/blog/zh-cn/sentinel-introduction-for-dubbo.md
@@ -1,4 +1,4 @@
-# Sentinel: Dubbo 服务的流量哨兵
+# Sentinel 为 Dubbo 服务保驾护航
 
 在复杂的生产环境下可能部署着成千上万的 Dubbo 服务实例,流量持续不断地进入,服务之间进行相互调用。但是分布式系统中可能会因流量激增、系统负载过高、网络延迟等一系列问题,导致某些服务不可用,如果不进行相应的控制可能导致级联故障,影响服务的可用性,因此我们需要一个能够保障服务稳定性的利器 —— Sentinel,来为 Dubbo 服务保驾护航。
 
@@ -18,7 +18,7 @@ Hystrix 熔断降级功能采用熔断器模式,在某个服务失败比率高
 
 ## Sentinel 与 Dubbo 整合的最佳实践
 
-Sentinel 提供了与 Dubbo 整合的模块 - [Sentinel Dubbo Adapter](https://github.com/sczyh30/alibaba-sentinel-dubbo-adapter),主要包括针对 Service Provider 和 Service Consumer 实现的 Filter。使用时用户只需引入以下模块(以 Maven 为例):
+Sentinel 提供了与 Dubbo 整合的模块 - [Sentinel Dubbo Adapter](https://github.com/dubbo/dubbo-sentinel-support),主要包括针对 Service Provider 和 Service Consumer 实现的 Filter。使用时用户只需引入以下模块(以 Maven 为例):
 
 ```xml
 <dependency>
@@ -58,6 +58,18 @@ Service Provider 用于向外界提供服务,处理各个消费者的调用请
 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`),则该限流规则对所有调用方生效。若限流规则配置了调用方则限流规则将仅对指定调用方生效。
+
+> 注:Dubbo 默认通信不携带对端 application name 信息,因此需要开发者在调用端手动将 application name 置入 attachment 中,provider 端进行相应的解析。Sentinel Dubbo Adapter 实现了一个 Filter 用于自动从 consumer 端向 provider 端透传 application name。若调用端未引入 Sentinel Dubbo Adapter,又希望根据调用端限流,可以在调用端手动将 application name 置入 attachment 中,key 为 `dubboApplication`。
+
+在限流日志中会也会记录调用方的名称,如:
+
+```
+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` 即为调用方名称。
+
 ## Service Consumer
 
 Service Consumer 作为客户端去调用远程服务。每一个服务都可能会依赖几个下游服务,若某个服务 A 依赖的下游服务 B 出现了不稳定的情况,服务 A 请求 服务 B 的响应时间变长,从而服务 A 调用服务 B 的线程就会产生堆积,最终可能耗尽服务 A 的线程数。我们通过用并发线程数来控制对下游服务 B 的访问,来保证下游服务不可靠的时候,不会拖垮服务自身。基于这种场景,推荐给 Consumer 配置**线程数模式**的限流,来保证自身不被不稳定服务所影响。限流粒度同样可以是服务接口和服务方法两种粒度。
diff --git a/md_json/blog.json b/md_json/blog.json
index 8bd12f8..c6b021b 100644
--- a/md_json/blog.json
+++ b/md_json/blog.json
@@ -38,7 +38,7 @@
     },
     {
       "filename": "sentinel-introduction-for-dubbo.md",
-      "__html": "<h1>Sentinel: Dubbo 服务的流量哨兵</h1>\n<p>在复杂的生产环境下可能部署着成千上万的 Dubbo 服务实例,流量持续不断地进入,服务之间进行相互调用。但是分布式系统中可能会因流量激增、系统负载过高、网络延迟等一系列问题,导致某些服务不可用,如果不进行相应的控制可能导致级联故障,影响服务的可用性,因此我们需要一个能够保障服务稳定性的利器 —— Sentinel,来为 Dubbo 服务保驾护航。</p>\n<h2>Sentinel 介绍</h2>\n<p><a href=\"https://github.com/alibaba/Sentinel\">Sentinel</a> 是阿里中间件团队开源的,面向分布式服务架构的轻量级流量控制产品,主要以流量为切入点,从流量控制、熔断降级、系统负载保护等多个维度来帮助用户保护服务的稳定性。</p>\n<p>Sentinel 主要功能有三部分:</p>\n<ul>\n<li>流量控制:Sentinel 可以针对不同的调用关系,以�
 ��同的运行指标(如 QPS、线程数、系统负载等) [...]
+      "__html": "<h1>Sentinel 为 Dubbo 服务保驾护航</h1>\n<p>在复杂的生产环境下可能部署着成千上万的 Dubbo 服务实例,流量持续不断地进入,服务之间进行相互调用。但是分布式系统中可能会因流量激增、系统负载过高、网络延迟等一系列问题,导致某些服务不可用,如果不进行相应的控制可能导致级联故障,影响服务的可用性,因此我们需要一个能够保障服务稳定性的利器 —— Sentinel,来为 Dubbo 服务保驾护航。</p>\n<h2>Sentinel 介绍</h2>\n<p><a href=\"https://github.com/alibaba/Sentinel\">Sentinel</a> 是阿里中间件团队开源的,面向分布式服务架构的轻量级流量控制产品,主要以流量为切入点,从流量控制、熔断降级、系统负载保护等多个维度来帮助用户保护服务的稳定性。</p>\n<p>Sentinel 主要功能有三部分:</p>\n<ul>\n<li>流量控制:Sentinel 可以针对不同的调用关系,以�
 ��同的运行指标(如 QPS、线程数、系统负载等) [...]
     },
     {
       "filename": "spring-boot-dubbo-start-stop-analysis.md",
@@ -69,6 +69,10 @@
     {
       "filename": "qcon-beijing-2018.md",
       "__html": "<h2>Dubbo roadmap is announced in QCon Beijing 2018</h2>\n<p>Ian Luo has delivered a great talk at QCon Beijing 2018, where the roadmap of Dubbo has also be announced. Please enjoy the <a href=\"https://github.com/dubbo/awesome-dubbo/raw/master/slides/qcon2018/dubbo-present-and-future.pdf\">slides</a>!</p>\n"
+    },
+    {
+      "filename": "sentinel-introduction-for-dubbo.md",
+      "__html": "<h1>Sentinel: The flow sentinel of Dubbo services</h1>\n<p>In large clusters there may be thousands of Dubbo service instances in production, with continuous traffic coming in. However, in distributed systems, some services may be unavailable due to various of failure such as traffic surge, high system load, and network latency. If no control actions are performed, this may cause cascading failure, affecting the availability of the service. So we need a powerful library  [...]
     }
   ]
 }
\ No newline at end of file
diff --git a/site_config/blog.js b/site_config/blog.js
index 2b0225e..dcf1bf4 100644
--- a/site_config/blog.js
+++ b/site_config/blog.js
@@ -4,6 +4,13 @@ export default {
     postsTitle: 'All posts',
     list: [
       {
+        title: 'Sentinel: The flow sentinel of Dubbo services',
+        author: 'Eric Zhao',
+        dateStr: 'July 27th, 2018',
+        desc: 'This blog introduces to the Sentinel and its best practice with Dubbo services. Sentinel is a powerful library that takes "flow" as the breakthrough point, and covers multiple fields including flow control, circuit breaking and load protection to guarantee service stability.',
+        link: '/blog/sentinel-introduction-for-dubbo.md',
+      },
+      {
         title: 'Tracking with Pinpoint',
         author: '@majinkai',
         dateStr: 'July 12th, 2018',