How Percentage Rollouts Work
When using a percentage rollout, the variation is determined by a hash generated using logic internal to the LaunchDarkly SDK. The hash function uses the given user key or attribute, the user's secondary attribute (if provided), the flag's key, and a hidden salt attribute stored in the feature flag to determine the bucketing assignment. The bucketing assignment is static. As long as the inputs and distribution percentages remain the same, users will receive the same variation.
Here's some diagrams to help visualize how bucketing works. Let's say our hashing function produces a number between 0 and 100000, which represents the full range of available buckets for a given feaure flag. With our current user key, we receive a bucket number of 10000:
Assuming we are distributing traffic evenly (50/50 split) between the variations, a bucket number of 10000 would land us in variation A:
However, if we were to adjust the traffic allocation to send 5% of traffic to variation A, and 95% to variation B, our user would change buckets:
This design ensures that percentage rollouts behave in a specific and predictable way:
- New users receive a random variation
- Returning users receive the same variation as long as rollout percentages remain the same
- Users can shift to different variations when rollout percentages change