Problem
The step that maps each user to a variant can silently break every test. At Wish, an A/A test showed a sample ratio mismatch (SRM): the observed split differed from the configured one although both variants were identical. SRM signals data quality problems that can change experiment outcomes. After weeks of digging, the team traced it to the randomization algorithm itself.
Example from the article: with a 10% exposure rate, the original two-step algorithm gave a non-uniform distribution of the bucket number, so a small control allocation received less traffic than configured.
Solution in brief
Draw one hash-based random integer per user and experiment, then use its first two digits for exposure and its last two digits for the bucket. Pick the hash function by testing uniformity, independence between experiments and speed: SpookyHash passed all checks and was the fastest.
Questions this case answers
- How to assign units to experiment variants deterministically so that the split is exact, independent across concurrent experiments, and cheap to compute at high request rates
- How to diagnose a sample ratio mismatch that appears even when both variants are identical
- How to find out why an A/A test shows a sample ratio mismatch?
- How to assign users to experiment variants with a hash so that buckets are uniform and independent across experiments?
Tools and methods
- A/A test — validates the assignment in production and exposes SRM
- Chi-square test — checks uniformity of bucket numbers and independence between two experiments
- Salted hashing (FNV, MD5, SpookyHash) — deterministic mapping of user ID to a random integer
Google or a one-time email code. No password.