Core Concepts

What are Feature Flags?

2 min read

Percentage Rollouts let you release a feature to a specific fraction of your users. FlagPilot calculates evaluations client-side in under 1 ms using a sticky, deterministic hash function — ensuring each user has a consistent experience without database round-trips.

Deterministic Hashing Algorithm

To allocate users to rollout buckets, the SDK hashes the user ID combined with the feature flag key using SHA-256. Taking the first 8 hex characters of the hash, parsing it as an integer, and applying a modulo 100 operation maps the user to a sticky bucket number between 0 and 99:

hashing.ts
function getRolloutBucket(userId: string, flagKey: string): number {
  const hash = sha256(`${userId}:${flagKey}`);
  const first8Hex = hash.substring(0, 8);
  const intValue = parseInt(first8Hex, 16);
  return intValue % 100;
}

If the calculated bucket number is strictly less than the target rollout percentage, the flag evaluates to true. For example, with a 20% rollout, buckets 0 through 19 receive the feature, while buckets 20 through 99 do not.

Step-by-Step Evaluation Lifecycle

When evaluating a feature flag, the SDK runs the following logic sequence:

1. Toggle State: Is the flag turned on in the environment?
2. Target Users: Is the user ID explicitly forced ON?
3. Hashing Bucket: Does the deterministic hash value fall in the rollout range?
4. Fallback Default: Serve default inactive configuration.

Feature flags (or feature toggles) let you modify application behavior at runtime without rebuilding, redeploying, or restarting your services.

Decoupling Code Deployments from Releases

Traditionally, releasing a feature required pushing code to production. If something went wrong, you had to roll back the release or rush a hotfix. Feature flags separate these phases:

  • Deployment: Push code behind a disabled toggle state. This is low risk because the new execution path is completely inactive.
  • Release: Enable the toggle in the dashboard for select users or environments. If errors spike, simply turn the flag off instantly.

Key Use Cases

  • 🚀 Canary Releases: Safely test features under load by rolling out to 1%, 5%, then 100% of users.
  • ⚡ Kill Switches: Instantly shut down failing third-party integrations or heavy resources to protect database infrastructure.
  • 🎨 A/B Testing: Split traffic between two design branches to measure conversion metrics.

FAQ

How does What are Feature Flags? interact with local caches?

Configurations are synced down using Edge Config or fallback REST triggers. The client automatically reads evaluations in-memory, resulting in sub-millisecond local evaluation times.

Where can I obtain support for What are Feature Flags??

You can open a support ticket in your dashboard, check the community roadmap, or consult the FlagPilot Platform Status page.

Was this page helpful?