Skip to main content

Long-Lived Feature Flags

Long-lived flags are permanent flags that remain in your application indefinitely. They're used for ongoing feature management and operational control.

Common Use Cases

1. Kill Switches

Kill switches are emergency controls that let you disable features or entire system components:

  • Disable problematic features quickly
  • Manage system load during incidents
  • Control access during maintenance
  • Implement graceful degradation

For example:

if (flagsmith.hasFeature("maintenance_mode")) {
showMaintenancePage();
} else {
showNormalContent();
}

2. Feature Management

Use flags with segments to control feature access:

  • Toggle features by subscription tier
  • Enable features for specific user groups
  • Control feature access by region/locale
  • Manage feature availability by app version

Example with segments:

// User with enterprise_plan trait will see the feature
if (flagsmith.hasFeature("advanced_analytics")) {
showEnterpriseFeatures();
}

3. Configuration Management

Use flag values to manage configuration:

  • API endpoint URLs
  • System limits and thresholds
  • Feature configuration parameters
  • Regional settings

Implementation Best Practices

1. Naming and Organization

Use clear, permanent-focused names:

feature_enterprise_analytics
kill_switch_api_v2
config_rate_limit

Use tags for organization:

  • kill-switch
  • config
  • permanent

2. Documentation

Document thoroughly:

  • Purpose and use cases
  • Impact when disabled
  • Related segments/configurations
  • Owner and responsible team

3. Protection Mechanisms

Prevent accidental changes:

4. Monitoring

Keep track of usage and impact:

  • Monitor through Flag Analytics
  • Set up alerts for critical flag changes
  • Track dependencies in your system
  • Regular audits of flag states

Maintenance Guidelines

  1. Regular Review

    • Validate flag configuration monthly
    • Update documentation as needed
    • Review segment rules and conditions
    • Check for obsolete configurations
  2. Testing

    • Regular testing of kill switches
    • Validate segment rules
    • Test default states
    • Verify degradation paths
  3. Change Management

    • Use Change Requests for updates
    • Schedule changes during low-impact windows
    • Coordinate changes across teams
    • Document all modifications
  4. Cleanup

    • Archive truly obsolete flags
    • Consolidate similar flags
    • Remove unused segments
    • Update documentation

Tools and Features

Flagsmith provides several tools for managing long-lived flags:

  1. Protection

    • Protected tags
    • Change Requests
    • Flag Owners
    • Environment-specific settings
  2. Monitoring

    • Flag Analytics
    • Change history
    • Audit logs
    • Usage tracking
  3. Management

    • Scheduled changes
    • Segment controls
    • Environment overrides
    • API access