-
Notifications
You must be signed in to change notification settings - Fork 36
/
abtest-doc.txt
140 lines (117 loc) · 3.31 KB
/
abtest-doc.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
----------默认分流规则设置--------------
设置host下的默认分流规则
curl -X POST -d 'host=domain.host.cn&appoint=[{"ip": "127.0.0.1","port": 8080,"weight":8},{"ip": "127.0.0.1","port": 8080,"weight":6}]' http://api.host.cn/admin/abtest/upstream
根据host下的获取默认分流规则
curl -X GET 'http://api.host.cn/admin/abtest/default?host=domain.host.cn'
根据host删除默认分流规则
curl -X DELETE 'http://api.host.cn/admin/abtest/default?host=domain.host.cn'
----------分流策略规则设置--------------
创建或者修改分流策略
curl -X POST -d 'appoint_id=1&appoint={ "divtype": "iprange","divdata": [{"range": { "start": "127.0.0.1", "end": "127.0.0.2"}, "upstream": { "ip": "127.0.0.1", "port": 8080 }} ]}' http://api.host.cn/admin/abtest/appoint
根据appoint_id获取分流策略
curl -X GET 'http://api.host.cn/admin/abtest/appoint?appoint_id=1'
根据appoint_id删除分流策略
curl -X DELETE 'http://api.host.cn/admin/abtest/appoint?appoint_id=1'
----------默认分流规则设置--------------
设置host使用分流规则
curl -X POST -d 'appoint_id=1&host=domain.host.cn' http://api.host.cn/admin/abtest/upstream
根据host删除分流规则
curl -X DELETE 'http://api.host.cn/admin/abtest/upstream?host=domain.host.cn'
根据host获取分流规则
curl -X GET 'http://api.host.cn/admin/abtest/upstream?host=domain.host.cn'
该域名是否存在分流规则
abtest:upstream:[domain] 分流id
默认分流规则
abtest:upstream:default
[
{
"ip": "127.0.0.1",
"port": 8080,
'weight':10
},
{
"ip": "127.0.0.1",
"port": 8080,
"weight":5
}
]
abtest:upstream:appoint:\d+
IP分流规则
{
"divtype": "iprange",
"divdata": [
{
"range": {
"start": "127.0.0.1",
"end": "127.0.0.2"
},
"upstream": {
"ip": "127.0.0.1",
"port": 8080
}
},
{
"range": {
"start": "127.0.0.3",
"end": "127.0.0.4"
},
"upstream": {
"ip": "127.0.0.1",
"port": 8080
}
}
]
}
用户UID分流规则
{
"divtype": "uidrange",
"divdata": [
{
"range": [
1,
2,
3,
4,
5
],
"upstream": {
"ip": "127.0.0.1",
"port": 8081
}
},
{
"range": [
1,
2,
3,
4,
5
],
"upstream": {
"ip": "127.0.0.1",
"port": 8080
}
}
]
}
设置用户UID分流规则后Headers带上X-Uid: 2,请求就会落在upstream 127.0.0.1:8081上,否则会落在默认upstream之中
请求
|
|
v 否
判断域名是否存在分流规则 -----> upstream default
|
| 是
|
v 无
根据分流ID获取分流规则 --------
| |
| |
| |
v V
根据分流规则计算 -----> upstream default
|
|
|
v
灰度upstream