HomeGetting Started
Feature Flags
Benchmarks of Feature Flags in Flutter
Alexandru Puiu
Alexandru Puiu
February 08, 2025
3 min

Table Of Contents

01
Why Performance Matters in Feature Flags
02
Our Benchmarking Approach
03
Benchmark Results
04
What These Numbers Mean
05
Performance Best Practices
06
Impact on Application Performance
07
Technical Implementation Details
08
Comparison with Other Solutions
09
Conclusion

Try it for free: 1 app, 2 environments, unlimited feature flags

Live Feature Toggles. No credit card required
Start Toggling

Why Performance Matters in Feature Flags

When implementing feature flags in a mobile application, performance is crucial. Feature flag evaluations happen frequently during your app’s lifecycle, and any latency in these evaluations can impact the user experience. This is especially important in Flutter applications, where smooth performance is a key selling point.

In this post, we’ll dive into the performance characteristics of the feature_flags_toggly Flutter package, sharing detailed benchmark results and what they mean for your application.

Our Benchmarking Approach

We conducted extensive performance testing of our Flutter feature flags implementation using a real-world device: a 6th generation iPad Mini Cellular. The benchmarks focused on measuring feature flag evaluation times, which is the most frequent operation in a feature flag system.

Our benchmark suite includes:

  • Warmup phase to ensure stable measurements
  • 1,000 iterations of feature flag evaluations
  • Comprehensive metrics including average, median, and percentiles
  • Multiple test runs to ensure consistency

The complete benchmark code is available on GitHub for transparency and reproducibility.

Benchmark Results

We ran two complete test cycles after our latest optimizations, and here are the detailed results:

First Test Run

Average: 156.41µs
Median: 145µs
P95: 257µs
Min: 36µs
Max: 1,173µs

Second Test Run

Average: 89.42µs
Median: 74µs
P95: 188µs
Min: 19µs
Max: 307µs

What These Numbers Mean

Let’s break down what these results mean for your application:

  1. Ultra-Fast Performance: Both test runs show exceptional performance, with the second run achieving remarkable sub-100µs average evaluation times. This is orders of magnitude faster than typical UI operations.

  2. Remarkable Consistency: The median times (145µs and 74µs) are consistently lower than their averages, demonstrating extremely stable performance. The second run shows particularly tight performance characteristics with even less variance.

  3. Exceptional Best Case: Minimum evaluation times as low as 19µs in the second run demonstrate the extreme efficiency of our local evaluation system after warm-up.

  4. Reliable Worst Case: Even the maximum times (1,173µsµs and 307µs) are well under acceptable thresholds for mobile applications. The second run shows particularly tight bounds on maximum latency.

  5. Tight Performance Bounds: The 95th percentile (P95) numbers of 257µs and 188µs show that the vast majority of evaluations complete in about a quarter of a millisecond, providing highly predictable performance for your application.

Performance Best Practices

To ensure you get the best performance from feature flags in your Flutter application:

  1. Use Local Evaluation: Our SDK performs all evaluations locally, eliminating network latency from the critical path.

  2. Enable Caching: Feature flag definitions are cached locally, ensuring fast access even in offline scenarios.

  3. Batch Updates: Flag definitions are updated in the background, without blocking flag evaluations.

  4. Minimize Complex Rules: While our evaluation engine is highly optimized, simpler targeting rules evaluate faster.

Impact on Application Performance

Based on these benchmarks, the performance impact of using feature flags in your Flutter application is minimal:

  • A typical feature flag evaluation takes less than 1ms
  • The overhead is negligible compared to typical UI operations
  • Background updates mean no blocking network calls
  • Local caching ensures consistent performance

Technical Implementation Details

Our Flutter SDK achieves these performance characteristics through several optimizations:

Multi-Layer Caching Strategy

  1. In-Memory Cache

    • Feature flags are cached in memory for instant access
    • Efficient data structures optimize lookup times
    • No disk I/O or network calls during evaluation
  2. Persistent Storage

    • Feature flags are written to local storage
    • Enables offline functionality
    • Persists across app restarts
    • Automatic recovery from memory cache misses
  3. Security Verification

    • Digital signatures verified on all definitions
    • Timestamp validation for freshness
    • Verification applies to both API responses and local storage
    • Ensures integrity of cached definitions

Smart Background Updates

void initToggly() async {
  await Toggly.init(
    appKey: '<your_app_key>',
    environment: '<your_app_environment>',
    // Default refresh interval is 3 minutes
    refreshInterval: Duration(minutes: 3),
    useSignedDefinitions: true,
  );
}

Our background update system includes several optimizations:

  1. Efficient Network Usage

    • ETag support to minimize bandwidth
    • 304 responses when definitions unchanged
    • Empty response bodies for unchanged definitions
    • Configurable refresh interval (default: 3 minutes)
  2. Non-Blocking Updates

    • Background refresh doesn’t block evaluations
    • Seamless transition to new definitions
    • No performance impact during updates

Evaluation Engine Optimizations

The evaluation engine uses efficient data structures and algorithms:

Feature(
  featureKeys: const ['ExampleFeature'],
  // Evaluations happen synchronously from cache
  child: const Text('Fast feature evaluation'),
)

Key optimizations include:

  • Optimized data structures for flag lookups
  • Minimal memory footprint
  • Zero-allocation path for common operations
  • Efficient boolean operations for multiple flags

Comparison with Other Solutions

While we don’t publish direct comparisons with other feature flag providers, our benchmarks demonstrate that the feature_flags_toggly package provides:

  • Sub-millisecond evaluation times
  • Minimal memory footprint
  • Efficient background updates
  • Robust offline support

Conclusion

The benchmark results demonstrate that our Flutter feature flags implementation provides excellent performance characteristics suitable for production applications. With average evaluation times under 1ms and consistent performance across thousands of evaluations, you can confidently use feature flags without worrying about performance impact.

The combination of local evaluation, efficient caching, and background updates ensures that feature flags add minimal overhead to your Flutter application while providing powerful feature management capabilities.

For more details about the benchmarks or to run them yourself, check out our benchmark code on GitHub.


Tags

feature-flagsflutterperformance

Try it for free: 1 app, 2 environments, unlimited feature flags

Live Feature Toggles. No credit card required
Alexandru Puiu

Alexandru Puiu

Software Engineer

Systems Engineering advocate, Software Engineer, Security Architect / Researcher, SQL/NoSQL DBA, and Certified Scrum Master with a passion for Distributed Systems, AI and IoT..

Expertise

.NET
RavenDB
Kubernetes

Social Media

githubtwitterwebsite

Related Posts

Flutter Feature Flags
A Comprehensive Guide to Implementing Feature Flags in Flutter
February 07, 2025
4 min

Subscribe To Our Newsletter

We'll only send worthwhile content we think you'll want, maybe once a month, and promise to never spam or sell your information!

Quick Links

HomeStories

Social Media