Prompt
feature flags with instant rollback and percentage rollout
Latest observation
Oct 13, 2026
OpenAI APIWeb search: off
If you want feature flags with instant rollback and percentage rollout, the core idea is:
- Feature flag = turn a feature on/off without redeploying
- Instant rollback = disable the flag immediately if something goes wrong
- Percentage rollout = expose the feature to only a small % of users first, then gradually increase
Minimal architecture
1) Flag definition
Store flags in a central service or config store:
{
"new_checkout": {
"enabled": true,
"rolloutPercent": 10,
"targets": ["beta-users", "internal"]
}
}
2) Evaluation logic
When a request comes in:
- Check if flag is globally disabled
- Check if user is in an allowlist/segment
- Otherwise, hash a stable user key and map it to 0–99
- Compare to rollout percentage
Example:
- user hash bucket =
23 - rollout =
10% - result = off
3) Instant rollback
Keep flag evaluation remote or cache-based with short TTL:
- Toggle flag to
false - Invalidate cache or push update via pub/sub
- All app instances stop serving it quickly
Deterministic percentage rollout
Use a stable hash so a user consistently sees the same version.
Pseudo-example:
def is_enabled(user_id, flag_name, rollout_percent):
bucket = hash(f"{flag_name}:{user_id}") % 100
return bucket < rollout_percent
This ensures:
- same user always gets same treatment
- no flickering between requests
Best practices
- Use stable identifiers like
user_id, not session ID - Add kill switch flags for critical features
- Keep short cache TTLs or push updates instantly
- Log flag decisions for debugging
- Separate:
- global on/off
- user targeting
- percentage rollout
Common rollout flow
- Release code behind flag
- Enable for internal users
- Roll out to 1%
- Increase to 5%, 10%, 25%, 50%, 100%
- If issues occur, set flag off immediately
Tools you can use
Managed options:
- LaunchDarkly
- Unleash
- Flagsmith
- ConfigCat
Build-your-own:
- Redis/Postgres-backed flag store
- CDN/config service + pub/sub invalidation
- Deterministic hashing for rollout
If you want, I can also provide:
- a Node.js/Python implementation
- a database schema for flags
- a production-ready rollout algorithm