Feature Flags vs A/B Testing: When to Use Each
- Average speed
- km/h
- Result
- Finish time
- 50 min
- You entered
- Distance
- 10 km
- You entered
Feature flags and A/B testing are both powerful tools for managing software releases, but they serve different purposes. Use feature flags to control when and to whom a feature is visible, and use A/B testing to measure which version of a feature performs better. In short, feature flags are about release management, while A/B testing is about experimentation.
Formula
The calculator computes your average pace and speed from a finish time and distance. The formulas are:
- Average pace = finish time (in minutes) ÷ distance (in km) → result in min/km
- Average speed = distance (in km) ÷ (finish time in minutes ÷ 60) → result in km/h
Variables: t = finish time in minutes, d = distance in kilometers.
Worked Example
Using the defaults: t = 50 minutes, d = 10 km.
Average pace = 50 ÷ 10 = 5.00 min/km.
Average speed = 10 ÷ (50/60) = 10 ÷ 0.8333 = 12.00 km/h.
So you ran at 5 minutes per kilometer, which is 12 km/h.
Background: What Are Feature Flags and A/B Testing?
Feature flags (also called feature toggles) are conditional statements in code that let you turn a feature on or off without deploying new code. You wrap a feature in a flag, and the flag’s state (on/off, or a percentage of users) is controlled remotely. This decouples deployment from release—you can ship code to production while keeping it hidden behind a flag.
A/B testing (also known as split testing) is a method of comparing two or more versions of a feature or page to see which performs better on a defined metric. Users are randomly assigned to a control group (A) or a variation (B), and the results are analyzed statistically to determine if the difference is significant.
How They Work: The Mechanics
Feature flags work by evaluating a condition at runtime. For example:
if (featureFlags.isEnabled("new-checkout")) {
renderNewCheckout();
} else {
renderOldCheckout();
}
The flag’s value can be changed via a configuration service, often with a dashboard, without redeploying. Flags can be scoped to specific users, groups, or percentages.
A/B testing requires more infrastructure. You need to:
- Define a hypothesis and a success metric (e.g., conversion rate).
- Split traffic randomly between control and treatment groups.
- Collect data over a sufficient sample size.
- Run a statistical test (e.g., t-test) to see if the difference is likely not due to chance.
Many A/B testing tools also use feature flags under the hood to serve different versions, but the key difference is the measurement layer.
When to Use Feature Flags
Feature flags shine in these scenarios:
- Progressive delivery: Roll out a feature to 10% of users, monitor for errors, then increase to 100%.
- Trunk-based development: Merge code frequently while keeping incomplete features hidden behind flags.
- Kill switches: Instantly disable a problematic feature without a hotfix.
- Environment-specific behavior: Enable a feature only for internal testing or staging.
- Decoupling deploy from release: Ship code on Friday, but turn it on Monday after team review.
If your goal is to reduce risk and increase deployment speed, feature flags are the right tool.
When to Use A/B Testing
A/B testing is appropriate when you need to make a data-driven decision about which version of a feature, design, or copy performs better. Common use cases:
- Optimizing conversion: Test two different checkout button colors or headline texts.
- Feature validation: Before fully releasing a new feature, test whether it improves engagement.
- User experience research: Compare layouts, navigation structures, or onboarding flows.
- Algorithm changes: Test a new recommendation algorithm against the old one.
If your question is “Which version is better?� rather than “When should I release this?�, A/B testing is the answer.
Can You Combine Them?
Yes, and in practice they are often used together. A common pattern is to use a feature flag to roll out a new feature to a small percentage of users, then run an A/B test within that group to compare the new feature against the old one. Once the test concludes, you can use the flag to gradually roll out the winning version to everyone.
For example, a team might flag a redesigned search bar, then run an A/B test on 10% of users comparing the new bar to the old one. After the test shows a significant improvement in click-through rate, they increase the flag to 50%, then 100%.
Common Pitfalls and Misconceptions
Misconception: Feature flags are just for A/B testing. Actually, feature flags are a release mechanism; A/B testing is an experimentation method. You can use flags without ever running a test.
Pitfall: Too many flags. Flags that are never cleaned up create technical debt. Always have a plan to remove flags once a feature is fully rolled out.
Pitfall: Confusing correlation with causation. A/B tests require proper randomization and sample size. Running a test for too short a time or with too few users can lead to false conclusions.
Pitfall: Not accounting for novelty effect. Users may behave differently simply because something is new. Run tests long enough to account for this.
Costs and Complexity
Feature flags are relatively simple to implement. You can start with a simple config file or environment variable, though at scale you’ll want a dedicated feature management service that offers targeting, audit logs, and SDKs. Costs are low, but the main cost is the engineering time to maintain flags.
A/B testing is more complex. You need statistical knowledge, proper tracking, and often a third-party tool (or in-house infrastructure). The cost includes tooling, data engineering, and the time to design and analyze experiments. However, the payoff is evidence-based decisions that can significantly improve key metrics.
Frequently Asked Questions
Can I use A/B testing without feature flags?
Yes, but it’s harder. Without flags, you’d need to deploy two separate versions of the app or use a client-side randomization script. Feature flags make it easier to serve different versions to different users without redeploying.
Are feature flags a replacement for A/B testing?
No. They solve different problems. Feature flags manage release risk; A/B testing provides evidence for decisions. You can have flags without testing, and you can test without flags (though it’s less convenient).
How long should an A/B test run?
Until you reach statistical significance, which depends on the effect size, sample size, and variance. A common rule of thumb is to run at least one full business cycle (e.g., a week) to account for daily variations, and to use a sample size calculator beforehand.
What is the difference between a feature flag and a kill switch?
A kill switch is a type of feature flag that is used specifically to turn off a feature in an emergency. All kill switches are feature flags, but not all feature flags are kill switches—flags can also be used for gradual rollouts, permissioning, or experimentation.
Do feature flags slow down the app?
There is a tiny performance cost from evaluating a flag condition, but it’s negligible in most cases. The bigger risk is adding too many flags that require network calls to fetch configurations. Use local caching to minimize latency.
Can A/B testing be done on the server side?
Yes. Server-side A/B testing is common for backend changes like pricing algorithms or recommendation models. The server assigns a variant and returns the appropriate response. It’s often more secure and faster than client-side testing.
Related
Formula used
in t | Finish time | min | 50 | 0 in d | Distance | km | 10 | 0 out pace | Average pace | min/km | t / d | 2 out speed | Average speed | km/h | d / (t / 60) | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.