mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 04:22:22 +00:00
fix img for ch5-9
This commit is contained in:
parent
c718dec526
commit
f435e89a90
@ -81,35 +81,13 @@ func isTrue(phone string) bool {
|
||||
|
||||
这种情况可以按照指定的百分比,返回对应的 true 和 false,和上面的单纯按照概率的区别是这里我们需要调用方提供给我们一个输入参数,我们以该输入参数作为源来计算哈希,并以哈希后的结果来求模,并返回结果。这样可以保证同一个用户的返回结果多次调用是一致的,在下面这种场景下,必须使用这种结果可预期的灰度算法:
|
||||
|
||||
```shell
|
||||
.---------.
|
||||
( user_2 )
|
||||
`---------'
|
||||
+--------+
|
||||
.---------. | set.V2 |---------------------+
|
||||
( user_1 ) +--------+ |
|
||||
`---------' | |
|
||||
+--------+ | |
|
||||
+--------------| set.V2 | | |
|
||||
| +--------+ | |
|
||||
| | | |
|
||||
v | | v
|
||||
+-------------+ | | +-------------+
|
||||
| storage_v1 | | | | storage_v2 |
|
||||
+-------------+ | | +-------------+
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
| v | |
|
||||
| +--------+ | |
|
||||
+------------->| get.V2 | | |
|
||||
+--------+ | |
|
||||
| |
|
||||
v |
|
||||
+--------+ |
|
||||
| get.V2 |<--------------------+
|
||||
+--------+
|
||||
```
|
||||

|
||||
|
||||
如果采用随机策略,可能会出现像下图这样的问题:
|
||||
|
||||

|
||||
|
||||
举个具体的例子,网站的注册环节,可能有两套API,按照用户ID进行灰度,分别是不同的存取逻辑。如果存储时使用了V1版本的API而获取时使用V2版本的API,那么就可能出现用户注册成功后反而返回注册失败消息的诡异问题。
|
||||
|
||||
## 5.9.3 如何实现一套灰度发布系统
|
||||
|
||||
@ -301,4 +279,4 @@ map[7:999475 5:1000359 1:999945 6:1000200 3:1000193 9:1000765 2:1000044 \
|
||||
4:1000343 8:1000823 0:997853]
|
||||
```
|
||||
|
||||
偏差基本都在 1/100 以内,是可以接受的。
|
||||
偏差都在1/100以内,可以接受。
|
||||
|
BIN
images/ch5-set-time-line.png
Normal file
BIN
images/ch5-set-time-line.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
BIN
images/ch5-set-time-line_2.png
Normal file
BIN
images/ch5-set-time-line_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Loading…
x
Reference in New Issue
Block a user