You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2019/05/26 04:09:53 UTC
[servicecomb-docs] 02/02: fix the discription of loadbalance
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-docs.git
commit 4a12cfe2b2f8764b421f0aeba8263305de31f19e
Author: yhs0092 <yh...@163.com>
AuthorDate: Sat May 25 18:57:31 2019 +0800
fix the discription of loadbalance
1. the default value of `continuousFailureThreshold` should be 5
2. correct the description on the routing by instance attributes
---
.../en_US/references-handlers/loadbalance.md | 40 ++++++++++++----------
.../zh_CN/references-handlers/loadbalance.md | 36 ++++++++++---------
2 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/java-chassis-reference/en_US/references-handlers/loadbalance.md b/java-chassis-reference/en_US/references-handlers/loadbalance.md
index bdc6f7a..58dfcf9 100644
--- a/java-chassis-reference/en_US/references-handlers/loadbalance.md
+++ b/java-chassis-reference/en_US/references-handlers/loadbalance.md
@@ -9,7 +9,7 @@ DiscoveryTree's logic is more complex, its processing progress is as below:
Load balancing can be configured in the Consumer processing chain, the handler name is loadbalance, as follows:
-```
+```yaml
servicecomb:
handler:
chain:
@@ -18,7 +18,7 @@ servicecomb:
```
POM dependence:
-```
+```xml
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>handler-loadbalance</artifactId>
@@ -43,30 +43,34 @@ This rule is enabled by default. If it is not needed, set servicecomb.loadbalanc
## Routing and forwarding by instance attributes
Users can specify the properties of microservice instances in microservice.yaml, or by calling service center APIs.
-```
+```yaml
instance_description:
properties:
- tag: mytag
+ tags:
+ tag_key: tag_value
```
Consumers can specify provider instances' attributes to determine which instances to call.
-```
+```yaml
servicecomb:
loadbalance:
- myservice:
+ # Here the "provider" means the config items below only take effect on the service named "provider"
+ # In cross-app invocation, the AppID should be prefixed, like "AppIDOfProvider:provider"
+ provider:
transactionControl:
options:
- tag: mytag
+ tags:
+ tag_key: expected_tag_value
```
-The above configuration shows that only myservice instances with the tag attribute mytag are called.
+The above configuration shows that only the instances of "provider" with the tag attribute `tag_key:expected_tag_value` are called.
This rule needs to be configured separately for each service. Global rule for all services is not supported.
-This rule is enabled by default, it can be disabled by setting servicecomb.loadbalance.filter.instanceProperty.enabled to false. The instance attributes based routing policy is implemented in InstancePropertyDiscoveryFilter.
+This rule is enabled by default, it can be disabled by setting `servicecomb.loadbalance.filter.instanceProperty.enabled` to false. The instance attributes based routing policy is implemented in `InstancePropertyDiscoveryFilter`.
## Instance isolation
Developers can configure instance-isolated parameters to temporarily drop access to the wrong instance, improving system reliability and performance. Below are the configuration items and default values:
-```
+```yaml
servicecomb:
loadbalance:
isolation:
@@ -74,10 +78,10 @@ servicecomb:
errorThresholdPercentage: 0
enableRequestThreshold: 5
singleTestTime: 60000
- continuousFailureThreshold: 2
+ continuousFailureThreshold: 5
```
-The interval of isolation calculation is 1 minute. According to the above configuration, in 1 minute, if the total number of requests is greater than 5, and more than 2 consecutive errors occur, the instance is isolated.
+The interval of isolation calculation is 1 minute. According to the above configuration, in 1 minute, if the total number of requests is greater than 5, and more than 2 consecutive errors occur, the instance is isolated.
The default value of errorThresholdPercentage is 0, indicates that the rule is ommited. The item should be a integer less than 100, for example 20, then within 1 minutes, if the total number of request is greater than 5 and [1] error rate is greater than 20% or [2] more than 2 consecutive errors occur, is instance is isolated.
@@ -94,7 +98,7 @@ The default instance state detection mechanism is to send a telnet instruction,
2. Configure SPI: Add META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing, the content is the full path of the implementation class
Developers can configure different isolation policies for different microservices. Just add a service name to the configuration item, for example:
-```
+```yaml
servicecomb:
loadbalance:
myservice:
@@ -110,7 +114,7 @@ This rule is enabled by default and can be turned off by setting servicecomb.loa
## Configuring route rules
Developers can specify load balancing policies through configuration items.
-```
+```yaml
servicecomb:
loadbalance:
strategy:
@@ -118,7 +122,7 @@ servicecomb:
```
Developers can configure policies for different microservices by adding a service name, for example:
-```
+```yaml
servicecomb:
loadbalance:
myservice:
@@ -130,7 +134,7 @@ Each policy has some specific configuration items.
* SessionStickiness
-```
+```yaml
servicecomb:
loadbalance:
SessionStickinessRule:
@@ -140,7 +144,7 @@ servicecomb:
## Set retry strategy
The load balancing module also supports the policy retry.
-```
+```yaml
servicecomb:
loadbalance:
retryEnabled: false
@@ -148,7 +152,7 @@ servicecomb:
retryOnSame: 0
```
Retry is not enabled by default. Developers can set different strategies for different services:
-```
+```yaml
servicecomb:
loadbalance:
myservice:
diff --git a/java-chassis-reference/zh_CN/references-handlers/loadbalance.md b/java-chassis-reference/zh_CN/references-handlers/loadbalance.md
index 0265379..bd8065b 100644
--- a/java-chassis-reference/zh_CN/references-handlers/loadbalance.md
+++ b/java-chassis-reference/zh_CN/references-handlers/loadbalance.md
@@ -8,7 +8,7 @@ DiscoveryTree的逻辑比较复杂,可以通过下面的处理流程了解其
![](/assets/loadbalance-001.png)
负载均衡适用于Consumer处理链,名称为loadbalance,示例如下:
-```
+```yaml
servicecomb:
handler:
chain:
@@ -17,7 +17,7 @@ servicecomb:
```
POM依赖:
-```
+```xml
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>handler-loadbalance</artifactId>
@@ -42,30 +42,32 @@ servicecomb:
## 根据实例属性进行路由转发
微服务可以指定实例的属性。实例属性可以在microservice.yaml中指定,也可以通过服务中心的API进行修改。
-```
+```yaml
instance_description:
properties:
- tag: mytag
+ tags:
+ tag_key: tag_value
```
消费者可以指定消费具备某些属性的实例,不访问其他实例
-```
+```yaml
servicecomb:
loadbalance:
- myservice:
+ provider: # 这里表示配置对名为"provider"的服务生效,如果是跨应用调用,则还需要加上AppID,如"AppIDOfProvider:provider"
transactionControl:
options:
- tag: mytag
+ tags:
+ tag_key: expected_tag_value
```
-上面的配置表示只访问myservice所有实例中tag属性为mytag的实例。
+上面的配置表示只访问myservice所有实例中`tag_key`属性为`expected_tag_value`的实例。
该规则需要给每个服务单独配置,未配置表示不启用该规则,不支持对于所有服务的全局配置。
-该规则默认启用,如果不需要使用,可以通过servicecomb.loadbalance.filter.instanceProperty.enabled进行关闭。根据实例属性进行路由转发功能在InstancePropertyDiscoveryFilter实现。
+该规则默认启用,如果不需要使用,可以通过`servicecomb.loadbalance.filter.instanceProperty.enabled`进行关闭。根据实例属性进行路由转发功能在`InstancePropertyDiscoveryFilter`实现。
## 实例隔离功能
开发者可以配置实例隔离的参数,以暂时屏蔽对于错误实例的访问,提升系统可靠性和性能。下面是其配置项和缺省值
-```
+```yaml
servicecomb:
loadbalance:
isolation:
@@ -73,7 +75,7 @@ servicecomb:
errorThresholdPercentage: 0
enableRequestThreshold: 5
singleTestTime: 60000
- continuousFailureThreshold: 2
+ continuousFailureThreshold: 5
```
隔离的统计周期是1分钟。按照上面的配置,在1分钟内,如果请求总数大于5,并且连续错误超过2次,那么就会将实例隔离。
@@ -91,7 +93,7 @@ servicecomb:
2. 配置SPI:增加META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing,内容为实现类的全名
开发者可以针对不同的微服务配置不一样的隔离策略。只需要给配置项增加服务名,例如:
-```
+```yaml
servicecomb:
loadbalance:
myservice:
@@ -107,7 +109,7 @@ servicecomb:
## 配置路由规则
开发者可以通过配置项指定负载均衡策略。
-```
+```yaml
servicecomb:
loadbalance:
strategy:
@@ -115,7 +117,7 @@ servicecomb:
```
开发者可以针对不同的微服务配置不一样的策略,只需要给配置项增加服务名,例如:
-```
+```yaml
servicecomb:
loadbalance:
myservice:
@@ -127,7 +129,7 @@ servicecomb:
* SessionStickiness
-```
+```yaml
servicecomb:
loadbalance:
SessionStickinessRule:
@@ -137,7 +139,7 @@ servicecomb:
## 设置重试策略
负载均衡模块还支持配置失败重试的策略。
-```
+```yaml
servicecomb:
loadbalance:
retryEnabled: false
@@ -145,7 +147,7 @@ servicecomb:
retryOnSame: 0
```
缺省情况未启用重试。同时也支持对不同的服务设置特殊的策略:
-```
+```yaml
servicecomb:
loadbalance:
myservice: