<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>流量管控 on Apache Dubbo</title><link>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/</link><description>Recent content in 流量管控 on Apache Dubbo</description><generator>Hugo</generator><language>zh-cn</language><atom:link href="https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/index.xml" rel="self" type="application/rss+xml"/><item><title>Dubbo 路由（router）机制及其如何实现流量管控介绍</title><link>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/introduction/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/introduction/</guid><description>&lt;p>Dubbo 提供了丰富的流量管控策略&lt;/p>
&lt;ul>
&lt;li>&lt;strong>地址发现与负载均衡&lt;/strong>，地址发现支持服务实例动态上下线，负载均衡确保流量均匀的分布到每个实例上。&lt;/li>
&lt;li>&lt;strong>基于路由规则的流量管控&lt;/strong>，路由规则对每次请求进行条件匹配，并将符合条件的请求路由到特定的地址子集。&lt;/li>
&lt;/ul>
&lt;p>服务发现保证调用方看到最新的提供方实例地址，服务发现机制依赖注册中心 (Zookeeper、Nacos、Istio 等) 实现。在消费端，Dubbo 提供了多种负载均衡策略，如随机负载均衡策略、一致性哈希负载、基于权重的轮询、最小活跃度优先、P2C 等。&lt;/p>
&lt;p>Dubbo 的流量管控规则可以基于应用、服务、方法、参数等粒度精准的控制流量走向，根据请求的目标服务、方法以及请求体中的其他附加参数进行匹配，符合匹配条件的流量会进一步的按照特定规则转发到一个地址子集。流量管控规则有以下几种：&lt;/p>
&lt;ul>
&lt;li>条件路由规则&lt;/li>
&lt;li>标签路由规则&lt;/li>
&lt;li>脚本路由规则&lt;/li>
&lt;li>动态配置规则&lt;/li>
&lt;/ul>
&lt;p>如果底层用的是基于 HTTP 的 RPC 协议 (如 REST、gRPC、Triple 等)，则服务和方法等就统一映射为 HTTP 路径 (path)，此时 Dubbo 路由规则相当于是基于 HTTP path 和 headers 的流量分发机制。&lt;/p>
&lt;blockquote>
&lt;p>Dubbo 中有应用、服务和方法的概念，一个应用可以发布多个服务，一个服务包含多个可被调用的方法，从抽象的视角来看，一次 Dubbo 调用就是某个消费方应用发起了对某个提供方应用内的某个服务特定方法的调用，Dubbo 的流量管控规则可以基于应用、服务、方法、参数等粒度精准的控制流量走向。&lt;/p>
&lt;/blockquote>
&lt;h2 id="router工作原理">Router工作原理&lt;/h2>
&lt;p>以下是 Dubbo 单个路由器的工作过程，路由器接收一个服务的实例地址集合作为输入，基于请求上下文 (Request Context) 和 (Router Rule) 实际的路由规则定义对输入地址进行匹配，所有匹配成功的实例组成一个地址子集，最终地址子集作为输出结果继续交给下一个路由器或者负载均衡组件处理。&lt;/p>
&lt;p>&lt;img alt="Router" src="https://deploy-preview-3199--dubbo.netlify.app/imgs/v3/feature/traffic/router1.png">&lt;/p>
&lt;p>通常，在 Dubbo 中，多个路由器组成一条路由链共同协作，前一个路由器的输出作为另一个路由器的输入，经过层层路由规则筛选后，最终生成有效的地址集合。&lt;/p>
&lt;ul>
&lt;li>Dubbo 中的每个服务都有一条完全独立的路由链，每个服务的路由链组成可能不通，处理的规则各异，各个服务间互不影响。&lt;/li>
&lt;li>对单条路由链而言，即使每次输入的地址集合相同，根据每次请求上下文的不同，生成的地址子集结果也可能不同。&lt;/li>
&lt;/ul>
&lt;p>&lt;img alt="Router" src="https://deploy-preview-3199--dubbo.netlify.app/imgs/v3/feature/traffic/router2.png">&lt;/p>
&lt;h2 id="路由规则分类">路由规则分类&lt;/h2>
&lt;h3 id="标签路由规则">标签路由规则&lt;/h3>
&lt;p>标签路由通过将某一个服务的实例划分到不同的分组，约束具有特定标签的流量只能在指定分组中流转，不同分组为不同的流量场景服务，从而实现流量隔离的目的。标签路由可以作为蓝绿发布、灰度发布等场景能力的基础。&lt;/p>
&lt;p>标签路由规则是一个非此即彼的流量隔离方案，也就是匹配&lt;code>标签&lt;/code>的请求会 100% 转发到有相同&lt;code>标签&lt;/code>的实例，没有匹配&lt;code>标签&lt;/code>的请求会 100% 转发到其余未匹配的实例。如果您需要按比例的流量调度方案，请参考示例 &lt;a href="https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/mannual/java-sdk/tasks/traffic-management/weight">基于权重的按比例流量路由&lt;/a>。&lt;/p>
&lt;p>&lt;code>标签&lt;/code>主要是指对 Provider 端应用实例的分组，目前有两种方式可以完成实例分组，分别是&lt;code>动态规则打标&lt;/code>和&lt;code>静态规则打标&lt;/code>。&lt;code>动态规则打标&lt;/code> 可以在运行时动态的圈住一组机器实例，而 &lt;code>静态规则打标&lt;/code> 则需要实例重启后才能生效，其中，动态规则相较于静态规则优先级更高，而当两种规则同时存在且出现冲突时，将以动态规则为准。&lt;/p></description></item><item><title>条件路由规则</title><link>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/condition-rule/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/condition-rule/</guid><description>&lt;p>条件路由规则将符合特定条件的请求转发到特定的地址实例子集上。规则首先对发起流量的请求参数进行匹配，符合匹配条件的请求将被转发到包含特定实例地址列表的子集。&lt;/p>
&lt;p>以下是一个条件路由规则示例。&lt;/p>
&lt;p>基于以下示例规则，所有 &lt;code>org.apache.dubbo.samples.CommentService&lt;/code> 服务 &lt;code>getComment&lt;/code> 方法的调用都将被转发到有 &lt;code>region=Hangzhou&lt;/code> 标记的地址子集。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">configVersion&lt;/span>: v3.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">scope&lt;/span>: service
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">force&lt;/span>: &lt;span style="color:#cb4b16">true&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">runtime&lt;/span>: &lt;span style="color:#cb4b16">true&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">enabled&lt;/span>: &lt;span style="color:#cb4b16">true&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">key&lt;/span>: org.apache.dubbo.samples.CommentService
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">conditions&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - method=getComment =&amp;gt; region=Hangzhou
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>可以看具体的例子代码： &lt;a href="https://github.com/apache/dubbo-samples/tree/master/4-governance/dubbo-samples-configconditionrouter/src/main/java/org/apache/dubbo/samples/governance">条件路由&lt;/a>&lt;/p>
&lt;h2 id="conditionrule">ConditionRule&lt;/h2>
&lt;p>条件路由规则主体。定义路由规则生效的目标服务或应用、流量过滤条件以及一些特定场景下的行为。&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th style="text-align: left">字段名&lt;/th>
 &lt;th style="text-align: left">类型&lt;/th>
 &lt;th style="text-align: left">&lt;strong>描述&lt;/strong>&lt;/th>
 &lt;th style="text-align: left">必填&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td style="text-align: left">configVersion&lt;/td>
 &lt;td style="text-align: left">string&lt;/td>
 &lt;td style="text-align: left">条件路由的版本，当前版本为 &lt;code>v3.0&lt;/code>&lt;/td>
 &lt;td style="text-align: left">是&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">scope&lt;/td>
 &lt;td style="text-align: left">string&lt;/td>
 &lt;td style="text-align: left">支持 &lt;code>service&lt;/code> 和 &lt;code>application&lt;/code> 两种规则&lt;/td>
 &lt;td style="text-align: left">是&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">key&lt;/td>
 &lt;td style="text-align: left">string&lt;/td>
 &lt;td style="text-align: left">应用到的目标服务或应用程序的标识符&lt;br/>&lt;br/>- 当 &lt;code>scope:service&lt;/code> 时, &lt;code>key&lt;/code>应该是该规则生效的服务名比如 org.apache.dubbo.samples.CommentService&lt;br/> - 当 &lt;code>scope:application&lt;/code> 时, then &lt;code>key&lt;/code>应该是该规则应该生效的应用名称，比如说my-dubbo-service.&lt;/td>
 &lt;td style="text-align: left">是&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">enabled&lt;/td>
 &lt;td style="text-align: left">bool&lt;/td>
 &lt;td style="text-align: left">规则是否生效 当 &lt;code>enabled:false&lt;/code> 时，规则不生效&lt;/td>
 &lt;td style="text-align: left">是&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">conditions&lt;/td>
 &lt;td style="text-align: left">string[]&lt;/td>
 &lt;td style="text-align: left">配置中定义的条件规则，详情可以看&lt;a href="https://cn.dubbo.apache.org/zh-cn/overview/core-features/traffic/condition-rule/#condition">条件规则&lt;/a>&lt;/td>
 &lt;td style="text-align: left">是&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">force&lt;/td>
 &lt;td style="text-align: left">bool&lt;/td>
 &lt;td style="text-align: left">T路由后实例子集为空时的行为。 &lt;code>true&lt;/code> 则抛出一个No Provider Exception。 &lt;code>false&lt;/code> 则忽略规则，直接去请求其他的实例。默认值是false&lt;/td>
 &lt;td style="text-align: left">否&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">runtime&lt;/td>
 &lt;td style="text-align: left">bool&lt;/td>
 &lt;td style="text-align: left">是否为每个 rpc 调用运行路由规则或使用路由缓存（如果可用）。默认值是false（false则走缓存，true不走缓存）&lt;/td>
 &lt;td style="text-align: left">否&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="condition">Condition&lt;/h2>
&lt;p>&lt;code>Condition&lt;/code> 为条件路由规则的主体，类型为一个复合结构的 string 字符串，如 &lt;code>method=getComment =&amp;gt; region=Hangzhou&lt;/code>。其中，&lt;/p></description></item><item><title>标签路由规则</title><link>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/tag-rule/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/tag-rule/</guid><description>&lt;p>标签路由通过将某一个服务的实例划分到不同的分组，约束具有特定标签的流量只能在指定分组中流转，不同分组为不同的流量场景服务，从而达到实现流量隔离的目的，可以作为蓝绿发布、灰度发布等场景能力的基础。目前有两种方式可以对实例打标，分别是&lt;code>动态规则打标&lt;/code>和&lt;code>静态规则打标&lt;/code>。&lt;code>动态规则打标&lt;/code> 可以在运行时动态的圈住一组机器实例，而 &lt;code>静态规则打标&lt;/code> 则需要实例重启后才能生效，其中，动态规则相较于静态规则优先级更高，而当两种规则同时存在且出现冲突时，将以动态规则为准。&lt;/p>
&lt;p>本文要讲的就是标签路由规则就是 &lt;code>动态规则打标&lt;/code>。&lt;/p>
&lt;p>标签路由是一套严格隔离的流量体系，对于同一个应用而言，一旦打了标签则这部分地址子集就被隔离出来，只有带有对应标签的请求流量可以访问这个地址子集，这部分地址不再接收没有标签或者具有不同标签的流量。&lt;/p>
&lt;p>举个例子，如果我们将一个应用进行打标，打标后划分为 tag-a、tag-b、无 tag 三个地址子集，则访问这个应用的流量，要么路由到 tag-a (当请求上下文 dubbo.tag=tag-a)，要么路由到 tag-b (dubbo.tag=tag-b)，或者路由到无 tag 的地址子集 (dubbo.tag 未设置)，不会出现混调的情况。&lt;/p>
&lt;p>标签路由的作用域是提供者应用，消费者应用无需配置标签路由规则。一个提供者应用内的所有服务只能有一条分组规则，不会有服务 A 使用一条路由规则、服务 B 使用另一条路由规则的情况出现。以下条件路由示例，在 &lt;code>shop-detail&lt;/code> 应用中圈出了一个隔离环境 &lt;code>gray&lt;/code>，&lt;code>gray&lt;/code> 环境包含所有带有 &lt;code>env=gray&lt;/code> 标识的机器实例。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">configVersion&lt;/span>: v3.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">force&lt;/span>: &lt;span style="color:#cb4b16">true&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">enabled&lt;/span>: &lt;span style="color:#cb4b16">true&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">key&lt;/span>: shop-detail
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">tags&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">name&lt;/span>: gray
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">match&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">key&lt;/span>: env
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">value&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">exact&lt;/span>: gray
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="tagrule">TagRule&lt;/h2>
&lt;p>标签路由规则主体。定义路由规则生效的目标应用、标签分类规则以及一些特定场景下的行为。&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th style="text-align: left">Field&lt;/th>
 &lt;th style="text-align: left">Type&lt;/th>
 &lt;th style="text-align: left">Description&lt;/th>
 &lt;th style="text-align: left">Required&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td style="text-align: left">configVersion&lt;/td>
 &lt;td style="text-align: left">string&lt;/td>
 &lt;td style="text-align: left">The version of the tag rule definition, currently available version is &lt;code>v3.0&lt;/code>&lt;/td>
 &lt;td style="text-align: left">Yes&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">key&lt;/td>
 &lt;td style="text-align: left">string&lt;/td>
 &lt;td style="text-align: left">The identifier of the target application that this rule is about to control&lt;/td>
 &lt;td style="text-align: left">Yes&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">enabled&lt;/td>
 &lt;td style="text-align: left">bool&lt;/td>
 &lt;td style="text-align: left">Whether enable this rule or not, set &lt;code>enabled:false&lt;/code> to disable this rule.&lt;/td>
 &lt;td style="text-align: left">Yes&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">tags&lt;/td>
 &lt;td style="text-align: left">Tag[]&lt;/td>
 &lt;td style="text-align: left">The tag definition of this rule.&lt;/td>
 &lt;td style="text-align: left">Yes&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">force&lt;/td>
 &lt;td style="text-align: left">bool&lt;/td>
 &lt;td style="text-align: left">The behaviour when the instance subset is empty after routing. &lt;code>true&lt;/code> means return no provider exception while &lt;code>false&lt;/code> means fallback to subset without any tags.&lt;/td>
 &lt;td style="text-align: left">No&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">runtime&lt;/td>
 &lt;td style="text-align: left">bool&lt;/td>
 &lt;td style="text-align: left">Whether run routing rule for every rpc invocation or use routing cache if available.&lt;/td>
 &lt;td style="text-align: left">No&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="tag">Tag&lt;/h2>
&lt;p>标签定义，根据 &lt;code>match&lt;/code> 条件筛选出一部分地址子集。&lt;/p></description></item><item><title>脚本路由规则</title><link>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/script-rule/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/script-rule/</guid><description>&lt;p>脚本路由为流量管理提供了最大的灵活性，所有流量在执行负载均衡选址之前，都会动态的执行一遍规则脚本，根据脚本执行的结果确定可用的地址子集。&lt;/p>
&lt;p>脚本路由只对消费者生效且只支持应用粒度管理，因此， &lt;code>key&lt;/code> 必须设置为消费者应用名；脚本语法支持多种，以 Dubbo Java SDK 为例，脚本语法支持 Javascript、Groovy、Kotlin 等，具体可参见每个语言实现的限制。&lt;/p>
&lt;blockquote>
&lt;p>脚本路由由于可以动态加载远端代码执行，因此存在潜在的安全隐患，在启用脚本路由前，一定要确保脚本规则在安全沙箱内运行。&lt;/p>
&lt;/blockquote>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">configVersion&lt;/span>: v3.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">key&lt;/span>: demo-provider
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">type&lt;/span>: javascript
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">enabled&lt;/span>: &lt;span style="color:#cb4b16">true&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">script&lt;/span>: |&lt;span style="color:#2aa198">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> (function route(invokers,invocation,context) {
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> var result = new java.util.ArrayList(invokers.size());
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> for (i = 0; i &amp;lt; invokers.size(); i ++) {
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> if (&amp;#34;10.20.3.3&amp;#34;.equals(invokers.get(i).getUrl().getHost())) {
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> result.add(invokers.get(i));
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> }
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> }
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> return result;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#2aa198"> } (invokers, invocation, context)); // 表示立即执行方法&lt;/span> 
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="scriptrule">ScriptRule&lt;/h2>
&lt;p>脚本路由规则主体。定义脚本规则生效的目标消费者应用、流量过滤脚本以及一些特定场景下的行为。&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th style="text-align: left">Field&lt;/th>
 &lt;th style="text-align: left">Type&lt;/th>
 &lt;th style="text-align: left">Description&lt;/th>
 &lt;th style="text-align: left">Required&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td style="text-align: left">configVersion&lt;/td>
 &lt;td style="text-align: left">string&lt;/td>
 &lt;td style="text-align: left">The version of the script rule definition, currently available version is &lt;code>v3.0&lt;/code>&lt;/td>
 &lt;td style="text-align: left">Yes&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">key&lt;/td>
 &lt;td style="text-align: left">string&lt;/td>
 &lt;td style="text-align: left">The identifier of the target application that this rule is about to apply to.&lt;/td>
 &lt;td style="text-align: left">Yes&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">type&lt;/td>
 &lt;td style="text-align: left">string&lt;/td>
 &lt;td style="text-align: left">The script language used to define &lt;code>script&lt;/code>.&lt;/td>
 &lt;td style="text-align: left">Yes&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">enabled&lt;/td>
 &lt;td style="text-align: left">bool&lt;/td>
 &lt;td style="text-align: left">Whether enable this rule or not, set &lt;code>enabled:false&lt;/code> to disable this rule.&lt;/td>
 &lt;td style="text-align: left">Yes&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">script&lt;/td>
 &lt;td style="text-align: left">string&lt;/td>
 &lt;td style="text-align: left">The script definition used to filter dubbo provider instances.&lt;/td>
 &lt;td style="text-align: left">Yes&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td style="text-align: left">force&lt;/td>
 &lt;td style="text-align: left">bool&lt;/td>
 &lt;td style="text-align: left">The behaviour when the instance subset is empty after after routing. &lt;code>true&lt;/code> means return no provider exception while &lt;code>false&lt;/code> means ignore this rule.&lt;/td>
 &lt;td style="text-align: left">No&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="script">Script&lt;/h2>
&lt;p>&lt;code>script&lt;/code> 为脚本路由规则的主体，类型为一个具有符合结构的 string 字符串，具体取决于 &lt;code>type&lt;/code> 指定的脚本语言。&lt;/p></description></item><item><title>动态配置规则</title><link>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/configuration-rule/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/configuration-rule/</guid><description>&lt;p>动态配置规则 (ConfigurationRule) 是 Dubbo 设计的在无需重启应用的情况下，动态调整 RPC 调用行为的一种能力，也称为动态覆盖规则，因为它是通过在运行态覆盖 Dubbo 实例或者 Dubbo 实例中 URL 地址的各种参数值，实现改变 RPC 调用行为的能力。&lt;/p>
&lt;p>使用动态配置规则，有以下几条关键信息值得注意：&lt;/p>
&lt;ul>
&lt;li>&lt;strong>设置规则生效过滤条件。&lt;/strong> 配置规则支持一系列的过滤条件，用来限定规则只对符合特定条件的服务、应用或实例才生效。&lt;/li>
&lt;li>&lt;strong>设置规则生效范围。&lt;/strong> 一个 rpc 服务有服务发起方（消费者）和服务处理方（提供者）两个角色，对某一个服务定义的规则，可以具体到限制是对消费者还是提供者生效。&lt;/li>
&lt;li>&lt;strong>选择规则管理粒度。&lt;/strong> Dubbo 支持从服务和应用两个粒度来管理和下发规则。&lt;/li>
&lt;/ul>
&lt;p>以下一个应用级别的配置示例，配置生效后，&lt;code>shop-detail&lt;/code> 应用下提供的所有服务都将启用 accesslog，对 &lt;code>shop-detail&lt;/code> 部署的所有实例生效。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">configVersion&lt;/span>: v3.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">scope&lt;/span>: application
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">key&lt;/span>: shop-detail
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">configs&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">side&lt;/span>: provider
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">parameters&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">accesslog&lt;/span>: &lt;span style="color:#2aa198">&amp;#39;true&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>以下是一个服务级别的配置示例，&lt;code>key: org.apache.dubbo.samples.UserService&lt;/code> 和 &lt;code>side: consumer&lt;/code> 说明这条配置对所有正在消费 UserService 的 Dubbo 实例生效，在调用失败后都执行 4 次重试。&lt;code>match&lt;/code> 条件进一步限制了消费端的范围，限定为只对应用名为 &lt;code>shop-frontend&lt;/code> 的这个消费端应用生效。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">configVersion&lt;/span>: v3.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">scope&lt;/span>: service
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">key&lt;/span>: org.apache.dubbo.samples.UserService
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">configs&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">match&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">application&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">oneof&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">exact&lt;/span>: shop-frontend
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">side&lt;/span>: consumer
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">parameters&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">retries&lt;/span>: &lt;span style="color:#2aa198">&amp;#39;4&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="configurationrule">ConfigurationRule&lt;/h2>
&lt;p>配置规则主体，定义要设置的目标服务或应用、具体的规则配置。具体配置规则 (configs) 可以设置多条。&lt;/p></description></item><item><title>限流 &amp; 熔断</title><link>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/circuit-breaking/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/circuit-breaking/</guid><description>&lt;p>由于微服务分布式的特点，如何构建稳定的微服务集群是一个很大的挑战，其中有两项非常关键的点值得关注&lt;/p>
&lt;ul>
&lt;li>流量控制 (Rate Limiting)&lt;/li>
&lt;li>熔断降级 (Circuit Breaking)&lt;/li>
&lt;/ul>
&lt;h2 id="流量控制">流量控制&lt;/h2>
&lt;p>&lt;strong>流量控制更多的是站在 Dubbo 服务提供者视角来保证服务稳定性&lt;/strong>，通过明确的为 Dubbo 服务设置请求上限阈值，确保服务所处理的请求数始终在一个合理范围之内，从而确保系统整体的稳定性。&lt;/p>
&lt;p>&lt;img alt="provider-rate-limit" src="https://deploy-preview-3199--dubbo.netlify.app/imgs/v3/feature/circuit-breaking/provider-rate-limit.png">&lt;/p>
&lt;p>根据服务的具体部署情况，服务所能处理的流量上限是一定的，当对服务的请求数量保持在合理的范围时，系统运行正常；而当请求数量严重超过服务处理能力时，如大促期间的流量洪峰等场景，就可能造成服务提供者端的资源过度消耗、负载过高，进而出现响应延迟、请求无应答、系统假死等情况。&lt;/p>
&lt;p>流量控制解决的问题和工作方式比较容易理解，而其使用的难点就是如何确定服务所能处理的流量最大值？&lt;/p>
&lt;ul>
&lt;li>一种模式是由用户预先设定一个固定的限流值，如 Dubbo 通过集成 Sentinel 等产品实现的限流能力即是这种模式
&lt;ul>
&lt;li>&lt;a href="https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/mannual/java-sdk/tasks/rate-limit/sentinel/">Dubbo Sentinel 流量控制&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>另一种方式是 Dubbo 框架自动根据系统或集群负载情况执行限流，相比用户预先设置限流值更加灵活方便，Dubbo 目前内置了自适应限流模式，具体可参见：
&lt;ul>
&lt;li>&lt;a href="https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/mannual/java-sdk/tasks/rate-limit/adaptive-concurrency-control">Java 自适应限流使用方式&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/reference/proposals/heuristic-flow-control/">Go 自适应限流使用方式&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/reference/proposals/heuristic-flow-control/">自适应限流设计原理&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h2 id="熔断降级">熔断降级&lt;/h2>
&lt;p>&lt;strong>熔断降级则是更多的从 Dubbo 服务消费者视角来保障系统稳定性的重要手段&lt;/strong>。一个服务往往需要调用更多的下游 Dubbo 服务来完成业务逻辑，这时下游服务的稳定性就会影响当前服务甚至整个系统的稳定性，熔断（Circuit Breaking）即是面向不稳定服务场景设计的，它能最大限度避免下游服务不稳定对上游服务带来的影响。&lt;/p>
&lt;p>而相比于熔断后直接返回调用失败信息，配合服务降级能力，我们可以继续调用预先设置好的服务降级逻辑，以降级逻辑的结果作为最终调用结果，以更优雅的返回给服务调用方。&lt;/p>
&lt;p>&lt;img alt="consumer-circuit-breaking" src="https://deploy-preview-3199--dubbo.netlify.app/imgs/v3/feature/circuit-breaking/consumer-circuit-breaking.png">&lt;/p>
&lt;p>如上图所示，Dubbo Consumer 依赖的下游的三个 Dubbo 服务，当 Service 3 出现不稳定的情况时（如响应时间变长、错误率增加等），从而 Consumer 调用 Service 3 的线程等资源就会产生堆积，如果此时我们不在 Consumer 侧做任何限制，则 Service 1 与 Service 2 的调用都会受到稳定性影响。通过熔断 Service 3 我们就能保证整个 Dubbo Consumer 服务的稳定性，不拖垮整个 Consumer 服务，熔断 Service 3 的方式可以有很多种实现，包括线程数、信号量、错误率等。&lt;/p></description></item><item><title>Mesh 路由规则</title><link>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/mesh-rule/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://deploy-preview-3199--dubbo.netlify.app/zh-cn/overview/what/core-features/traffic/mesh-rule/</guid><description>&lt;p>Dubbo Mesh 路由规则是基于 Istio 的 VirtualService、DestinationRule 改造而来，总体思路和格式可以参考 Istio 流量管控规则参考手册：&lt;a href="https://istio.io/latest/docs/reference/config/networking/virtual-service/">Istio VirtualService&lt;/a> 和 &lt;a href="https://istio.io/latest/docs/reference/config/networking/destination-rule/">Istio DestinationRule&lt;/a>&lt;/p>
&lt;p>本文描述了 Dubbo Mesh 路由规则的设计原理，以及它和 Istio 规则的差异等。参考链接：https://www.yuque.com/docs/share/c132d5db-0dcb-487f-8833-7c7732964bd4?#。&lt;/p>
&lt;h3 id="基本思想">基本思想&lt;/h3>
&lt;p>基于路由链，采用Pipeline的处理方式，如下图所示：&lt;/p>
&lt;p>&lt;img alt="route-rule1.png" src="https://deploy-preview-3199--dubbo.netlify.app/imgs/user/route-rule1.png">&lt;/p>
&lt;p>可以把路由链的逻辑简单的理解为 target = rn(&amp;hellip;r3(r2(r1(src))))。对于每一个 router 内部的逻辑，可以抽象为输入地址 addrs-in 与 router 中按全量地址 addrs-all 实现切分好的 n 个互不相交的地址池 addrs-pool-1 &amp;hellip; addrs-pool-n 按实现定义好的规则取交集作为输出 addrs-out。以此类推，完成整个路由链的计算。&lt;/p>
&lt;p>&lt;img alt="route-rule2.png" src="https://deploy-preview-3199--dubbo.netlify.app/imgs/user/route-rule2.png">&lt;/p>
&lt;p>另外一方面，如果 router(n) 需要执行 fallback 逻辑的时候，那么需要经过 router(n) 就应该决定好 fallback 逻辑&lt;/p>
&lt;h3 id="fallback-处理原则">fallback 处理原则&lt;/h3>
&lt;p>由于多个 router 之间多个条件组件之后，很容易出现地址被筛选为空的情况，那么我们需要针对这情况进行 fallback 处理，保证业务在正确性的前提下，能够顺利找到有效地址。&lt;/p>
&lt;p>首先我们看一下以下规则&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">apiVersion&lt;/span>: service.dubbo.apache.org/v1alpha1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">kind&lt;/span>: VirtualService
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">metadata&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">name&lt;/span>: demo-route
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">spec&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">hosts&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - demo // 统一定义为应用名
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">dubbo&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">service&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">exact&lt;/span>: com.taobao.hsf.demoService:1.0.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">exact&lt;/span>: com.taobao.hsf.demoService:2.0.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">routedetail&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">name&lt;/span>: sayHello-String-method-route
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">match&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">method&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">name_match&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">exact&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;sayHello&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> .....
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">argp&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - string
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">route&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">destination&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">host&lt;/span>: demo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">subset&lt;/span>: v1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">fallback&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">destination&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">host&lt;/span>: demo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">subset&lt;/span>: v2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">fallback&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">destination&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">host&lt;/span>: demo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">subset&lt;/span>: v3
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">name&lt;/span>: sayHello-method-route
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">match&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">method&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">name_match&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">exact&lt;/span>: &lt;span style="color:#2aa198">&amp;#34;s-method&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">route&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">destination&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">host&lt;/span>: demo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">subset&lt;/span>: v2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">fallback&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">destination&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">host&lt;/span>: demo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">subset&lt;/span>: v3
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">name&lt;/span>: interface-route
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">route&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">destination&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">host&lt;/span>: demo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">subset&lt;/span>: v3
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">service&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ....
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>---
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">apiVersion&lt;/span>: service.dubbo.apache.org/v1alpha1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">kind&lt;/span>: DestinationRule
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">metadata&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">name&lt;/span>: demo-route
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#268bd2">spec&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">host&lt;/span>: demo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">subsets&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">name&lt;/span>: v1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">labels&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">sigma.ali/mg&lt;/span>: v1-host
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">name&lt;/span>: v2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">labels&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">sigma.ali/mg&lt;/span>: v2-host
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#268bd2">name&lt;/span>: v3
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">labels&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#268bd2">sigma.ali/mg&lt;/span>: v3-host
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>我们以脚本路由为例，这个脚本路由的匹配条件是遵循一个原则的，就是匹配的范围是从精确到广泛的一个过程，在这个示例来说，就是 sayHello(string)参数 -&amp;gt; sayHello 方法 -&amp;gt; 接口级路由 的一个匹配查找过程。&lt;/p></description></item></channel></rss>