Deterministic Percentage Rollout for a Feature Toggle Service
Last updated: November 29, 2026
Quick Overview
Write a function that decides whether a feature toggle is on for a given user, supporting a global kill switch, allow and deny lists, an optional user-group filter and a percentage rollout that stays stable for each user as the percentage increases.
Thoughtworks
November 29, 20260
0
0 solved
Write a function that decides whether a feature toggle is on for a given user, supporting a global kill switch, allow and deny lists, an optional user-group filter and a percentage rollout that stays stable for each user as the percentage increases.
Feature toggles and trunk-based development are long-standing Thoughtworks practices, so a short screen about evaluating toggles for a client's release is a natural fit. The interviewer checks rule precedence, deterministic hashing, and whether you reason about rollouts that must not flip users back and forth.
What the Interviewer Expects
- States a clear precedence: kill switch, deny, allow, group filter, percentage
- Uses a stable hash of flag name plus user id, not random()
- Explains why raising the percentage only adds users
- Salts by flag name so the same users are not always the guinea pigs
- Writes a quick test that the observed share is near the target
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you roll out to 5% of accounts rather than 5% of users?
- Where should evaluation run: server, client SDK or edge, and what are the trade-offs?
- How do you stop toggles from piling up as technical debt in a client codebase?
- How would you test code paths behind a toggle in CI?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: a flag config (name, enabled, percent 0 to 100, allow set, deny set, optional groups) and a user (id, group). Output: boolean. A user who is in the rollout at 30% must still be in it at 50%, an...
High-Level Design
Precedence top to bottom: if the flag is disabled, off. Deny list wins over everything else, then allow list (useful for QA accounts). If groups are set, users outside them are off. Otherwise hash `fl...