-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8d2ece
commit 8a2c868
Showing
4 changed files
with
621 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,7 @@ | |
## 4. 全链路透传 | ||
|
||
查看[全链路透传](transmission.md) | ||
|
||
## 5. 服务治理模型 | ||
|
||
查看[服务治理模型](governance.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,307 @@ | ||
服务治理模型 | ||
=== | ||
|
||
## 1. 统一治理层级 | ||
|
||
统一HTTP和传统RPC的治理策略配置层级 | ||
``` | ||
. | ||
└── 服务 | ||
├── 分组* | ||
│ ├── 路径* | ||
│ │ ├── 方法* | ||
``` | ||
服务治理策略放在分组、路径和方法上,可以逐级设置,下级默认继承上级的配置 | ||
|
||
服务的默认策略设置到默认分组`default`上 | ||
|
||
| 类型 | 服务 | 分组 | 路径 | 方法 | | ||
|-----------|-----|----|-------|--------| | ||
| HTTP | 域名 | 分组 | URL路径 | HTTP方法 | | ||
| RPC 应用级注册 | 应用名 | 分组 | 接口名 | 方法名 | | ||
| RPC 接口级注册 | 接口名 | 分组 | / | 方法名 | | ||
|
||
## 2. 服务策略 | ||
### 2.1 服务多活策略 | ||
|
||
| 元素 | 说明 | | ||
|----------|----------------------------| | ||
| 参与 | 是否写方法,需要在容灾切换的时候禁止写数据 | | ||
| 变量表达式 | 单元化场景,可设置从方法参数获取路由变量 | | ||
| 单元策略 | 非单元化、本单元优先、单元化和中心 | | ||
| 默认单元容错阈值 | 本单元优先策略下,当单元指标小于该阈值可以跨单元访问 | | ||
| 单元容错阈值 | 设置每个单元的容错阈值 | | ||
| 分区策略 | 本分区优先、不限 | | ||
| 默认分区容错阈值 | 本分区优先策略下,当分区指标小于该阈值可以跨单元访问 | | ||
| 分区容错阈值 | 设置每个分区的容错阈值 | | ||
|
||
```json | ||
{ | ||
"writeProtect": false, | ||
"variableExpression": null, | ||
"unitPolicy": "PREFER_LOCAL_UNIT", | ||
"defaultUnitThreshold": 1, | ||
"unitRemotes": [ | ||
{ | ||
"name": "unit2", | ||
"type": "INSTANCES", | ||
"threshold": 1 | ||
} | ||
], | ||
"cellPolicy": "PREFER_LOCAL_CELL", | ||
"defaultCellThreshold": 3, | ||
"cellRemotes": [ | ||
{ | ||
"name": "cell1", | ||
"type": "INSTANCES", | ||
"threshold": 4 | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### 2.2 服务泳道策略 | ||
|
||
| 元素 | 说明 | | ||
|----------|----------------------------| | ||
| 泳道空间 | 配置参与那些泳道空间 | | ||
|
||
```json | ||
{ | ||
"lanePolicies": [ | ||
{ | ||
"laneSpaceId": "lane-space-1" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### 2.3 服务集群策略 | ||
|
||
| 元素 | 说明 | | ||
|------|-----------------------------------------------| | ||
| 类型 | 故障切换、快速失败、失败可容忍 | | ||
| 重试策略 | 当类型为故障切换,可配置重试策略,包括重视次数、重试时间间隔、超时时间、重试状态和重试异常 | | ||
|
||
```json | ||
{ | ||
"clusterPolicy": { | ||
"type": "failover", | ||
"retryPolicy": { | ||
"retry": 10, | ||
"retryInterval": 1000, | ||
"timeout": 5000, | ||
"retryStatuses": [ | ||
500, | ||
502 | ||
], | ||
"retryExceptions": [ | ||
"java.lang.NullPointException" | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### 2.4 服务负载均衡策略 | ||
|
||
| 元素 | 说明 | | ||
|----|---------| | ||
| 类型 | 随机权重和轮询 | | ||
| 粘连 | 是否开启粘连 | | ||
|
||
```json | ||
{ | ||
"loadBalancePolicy": { | ||
"policyType": "ROUND_ROBIN", | ||
"stickyType": "NONE" | ||
} | ||
} | ||
``` | ||
|
||
### 2.5 服务限流策略 | ||
|
||
| 元素 | 说明 | | ||
|--------|---------------------------------------| | ||
| 名称 | 限流策略名称 | | ||
| 类型 | 限流实现类型,包括`Resilience4j`和`TokenBucket` | | ||
| 滑动窗口 | 配置滑动窗口信息,包括调用次数和时间窗 | | ||
| 最大等待时间 | 最大等待时间 | | ||
| 参数 | 限流操作需要的参数 | | ||
| 条件 | 限流开启的条件 | | ||
|
||
```json | ||
{ | ||
"rateLimitPolicies": [ | ||
{ | ||
"name": "limit-rule-1", | ||
"version": 1704038400000, | ||
"strategyType": "Resilience4j", | ||
"slidingWindows": [ | ||
{ | ||
"threshold": 1, | ||
"timeWindowInMs": 1000 | ||
}, | ||
{ | ||
"threshold": 3, | ||
"timeWindowInMs": 2000 | ||
} | ||
], | ||
"maxWaitMs": 100, | ||
"actionParameters": { | ||
}, | ||
"relationType": "AND", | ||
"conditions": [ | ||
{ | ||
"type": "header", | ||
"opType": "EQUAL", | ||
"key": "x-live-ext-demo", | ||
"value": [ | ||
"abc" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### 2.6 服务并发控制策略 | ||
|
||
| 元素 | 说明 | | ||
|-------|-------------------------| | ||
| 名称 | 并发控制策略名称 | | ||
| 类型 | 限流实现类型,包括`Resilience4j` | | ||
| 最大并发数 | 最大并发数 | | ||
| 最大等待时间 | 最大等待时间 | | ||
| 参数 | 限流操作需要的参数 | | ||
| 条件 | 限流开启的条件 | | ||
|
||
```json | ||
{ | ||
"concurrencyLimitPolicies": [ | ||
{ | ||
"name": "limit-rule-2", | ||
"version": 1704038400000, | ||
"strategyType": "Resilience4j", | ||
"maxConcurrency": 10, | ||
"maxWaitMs": 100, | ||
"actionParameters": { | ||
}, | ||
"relationType": "AND", | ||
"conditions": [ | ||
{ | ||
"type": "header", | ||
"opType": "EQUAL", | ||
"key": "x-live-ext-demo", | ||
"value": [ | ||
"abc" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### 2.7 服务标签路由策略 | ||
|
||
| 元素 | 说明 | | ||
|----|-----------------------------| | ||
| 名称 | 策略名称 | | ||
| 规则 | 定义多个规则,每个规则包括开启条件、目标权重和目标标签 | | ||
|
||
```json | ||
{ | ||
"routePolicies": [ | ||
{ | ||
"name": "route1", | ||
"tagRules": [ | ||
{ | ||
"order": 5, | ||
"relationType": "AND", | ||
"conditions": [ | ||
{ | ||
"opType": "EQUAL", | ||
"type": "header", | ||
"key": "x-live-unit", | ||
"values": [ | ||
"unit1" | ||
] | ||
} | ||
], | ||
"destinations": [ | ||
{ | ||
"weight": 100, | ||
"relationType": "AND", | ||
"conditions": [ | ||
{ | ||
"opType": "EQUAL", | ||
"key": "unit", | ||
"values": [ | ||
"unit1" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### 3. 服务策略完整骨架 | ||
|
||
下面以json格式展示了服务策略 | ||
|
||
```json | ||
[ | ||
{ | ||
"name": "service-provider", | ||
"serviceType": "HTTP", | ||
"version": 0, | ||
"groups": [ | ||
{ | ||
"name": "default", | ||
"defaultGroup": true, | ||
"servicePolicy": { | ||
"livePolicy": { | ||
}, | ||
"lanePolicies": [ | ||
], | ||
"clusterPolicy": { | ||
}, | ||
"loadBalancePolicy": { | ||
}, | ||
"rateLimitPolicies": [ | ||
], | ||
"concurrencyLimitPolicies": [ | ||
], | ||
"routePolicies": [ | ||
] | ||
}, | ||
"paths": [ | ||
{ | ||
"path": "/echo", | ||
"matchType": "EQUAL", | ||
"servicePolicy": { | ||
}, | ||
"methods": [ | ||
{ | ||
"name": "GET", | ||
"servicePolicy": { | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
|
Oops, something went wrong.