You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/configure_flag/rollout-strategies/percentage.md
+67Lines changed: 67 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,73 @@ If the sum of your percentages is not equal to 100 this is not a problem, we are
24
24
_**example**: if you have 2 variations and you set `variation1: 10` and `variation2: 50` it will be equivalent to `variation1: 10/60` and `variation2: 50/60`._
25
25
:::
26
26
27
+
## How percentage rollout works?
28
+
29
+
GO Feature Flag uses a deterministic hashing algorithm to ensure consistent user assignment to variations. Here's how it works:
30
+
31
+
### Hash computation
32
+
33
+
For each evaluation, GO Feature Flag computes a hash based on the **targeting key** (also called bucketing key) and the **flag name**:
This hash produces a value between `0` and `maxPercentage` (which is the sum of all percentages). The hash function ensures that the same user (with the same targeting key) will always get the same hash value for a given flag, providing consistent assignment.
40
+
41
+
### Bucket assignment
42
+
43
+
All variations that are part of the percentage rollout are sorted by **reverse alphabetical**. This ensures consistent bucket assignment across evaluations.
44
+
45
+
For example, if you have the following percentages:
46
+
```yaml
47
+
percentage:
48
+
- varC: 20
49
+
- varB: 30
50
+
- varA: 50
51
+
```
52
+
53
+
After sorting by inverse alphabetical order, the buckets are assigned as follows:
54
+
- **0 to 20**: assigned to `varC`
55
+
- **20 to 50**: assigned to `varB`
56
+
- **50 to 100**: assigned to `varA`
57
+
58
+
The hash value determines which bucket the user falls into, and thus which variation they receive.
59
+
60
+
Since it is pure hash based, GO Feature Flag will always assign the evaluation context to the same bucket even if your evaluation is done on a different server or if you restart your relay-proxy.
61
+
62
+
### Impact of changing percentages
63
+
64
+
When you have two variations, adjusting the percentages simply increases or decreases the number of users assigned to each variation.
65
+
This allows you to gradually roll out a feature in a predictable and straightforward way.
But if you have **more than 2 variations**, this can have an impact on how your bucketing works.
71
+
When you change the percentage configuration, **all buckets are recalculated**, which means users may be reassigned to different variations. This happens because the bucket boundaries shift based on the new percentages.
72
+
73
+
For example, if you change the configuration to:
74
+
```yaml
75
+
percentage:
76
+
- varC: 30
77
+
- varB: 30
78
+
- varA: 40
79
+
```
80
+
81
+
The new bucket assignments become:
82
+
- **0 to 30**: assigned to `varC`
83
+
- **30 to 60**: assigned to `varB`
84
+
- **60 to 100**: assigned to `varA`
85
+
86
+
As you can see in the diagram below, changing percentages shifts the bucket boundaries, which can move users from one variation to another:
The deterministic hashing ensures that the same user will always get the same variation for a given configuration. However, when you change percentages, the bucket boundaries change, which may cause some users to be reassigned to different variations.
0 commit comments