Article

7min read

Fun with Flags: Where to Store Feature Flags

So far, in our Fun with Flags series, we have looked at some important best practices when it comes to feature flags including naming conventions and access control.

In this part of our series, we will be looking at the different ways feature flags can be stored based on which category they belong to.

Let’s start with a simple definition of feature flags. A feature flag is a software development practice that allows you to decouple code deployment from release, enabling quicker and safer releases.

They allow you to enable or disable functionality remotely without changing code. At its most basic, a feature flag is a file separate from your code file.

For a more comprehensive overview of feature flags, read our definitive guide to feature flags.

Configuration files

You could start off deploying feature flags using a configuration file. This is the simplest implementation method. A config file is usually used to store application settings and some flags just fall into this category. 

However, this might be time-consuming as developers may need to redeploy the application after each value update to reflect the changed value. Redeploying can take some time and if your changes are mission critical you may lose some reactivity. Configuration files also don’t allow you to make context-specific decisions, meaning that flags will either be on or off for all users (only hold one specific value at a time).

This makes the most sense when you’re just starting out your feature flag journey and you wish to experiment with feature flags at a smaller scale. Additionally, this could be a viable option for static flags like a release toggle, which are feature flags that enable trunk-based development to support dev teams as they write new features.

For example, a developer may need for a kill switch to work instantaneously to kill off a buggy feature while the flipping time for a release toggle from off to on can take longer.

Such static flags, as their name implies, will be relatively static and will only change through code or configuration file changes.

To better understand how feature flag values should be stored, it’s best to start with the different categories of flags, which are based on longevity and dynamism.

Short vs long lived flags

Longevity of a feature flag, as the name suggests, refers to how long a flag will remain in your code. 

Some types of flags are short-lived such as release toggles while others such as kill switches are long-lived; they will stay in your codebase often for years.

This distinction between short- and long-lived flags will influence how you go about implementing its toggle point. The longer the lifetime of a flag, the more careful you’ll need to be in choosing about choosing the toggle point location.

Keep reading: Short vs Long-lived Feature Flags (Fun with Flag series)

Dynamic vs static flags

There are obviously different types of flags, which means these different flags cannot be managed and configured the same way. Dynamism refers to how much we need to modify a flag in its lifetime.

Therefore, feature flags can be broken down into two categories depending on how they are hosted:

  • Static flags-as already mentioned, these are usually hosted by a file that only changes when you want it to. These flags get hard-coded into the app at build time so the flag configuration is stored in the actual code.
  • Dynamic flags-usually hosted by a service that will change the value of the flag depending on the values you send with the request. This type of flag can be changed at runtime allowing for dynamic control of code execution on a user-by-user or session-by-session basis.

This means that the configuration for some types of flags needs to be more dynamic than others. For example, if you want to change a value based on a shared attribute among groups of users. 

Alternative storage method: database

As an alternative to config files, feature flags can be stored in some sort of database. It is a convenient place to store your settings and they can often be easily updated.

So if you see the number of flags in your system and you need more granular controls, you might opt to deploy your flags via a database. This would allow you to target features to individual users. 

Moreover, having flags in a database means that not only your developers can change values assigned to flags but also your product teams, thereby reducing dependency. This assumes that some kind of dashboard or management system is in place for other people to easily interact with the database. You’ll also probably want to keep track of changes to this database.

However, you still wouldn’t be able to do gradual rollouts or targeting users based on IDs or attributes or monitor metrics. In other words, it limits the extent of your user segmetting. 

Consequently, while config files and databases are quick solutions, when you’re just starting out, they are not good in the long-term if you’re looking to scale or use more dynamic flags.

You might then consider a feature flag open source solution, which allows for simple user segmentation and controlled rollouts. Nevertheless, such solutions wouldn’t allow you to track who made changes or limit access and they are generally language specific. This could be a problem if your application uses multiple languages so you would need to deploy multiple solutions.

Feature management services

The most dynamic flags are those whose state depends on the current user. Dynamic flags need to be hosted by a service rather than a static file mentioned previously. This is because feature flag services allow you to serve different values to different types of users at runtime.

In that sense, you would target values based on user IDs or according to percentage, i.e. a feature can be seen by x% of users, or according to a certain group the users belong to, using some user traits as targeting criteria.

This also works if you’re experimenting with features, with a traditional A/B testing approach, and you need to randomly put users in different groups so the user’s ID would be sent to the service to place in a group accordingly.

Such IDs (that could be stored in cookies or localStorage…) are also useful when testing internally where a feature is turned on for internal users as detected via a special ID value. Developers would then turn these features on for themselves to make sure it’s working as it should and test directly in production.

In such situations, you would opt for a third party service to fetch values of the feature flags.

Such feature flag services would, therefore, also allow you to to choose values for each flag depending on specific attributes such as the country users are from.

For example, AB Tasty’s flagging functionality allows you to assign specific flag values to different user segments. So, internal users would be served one value and would then see the new feature while external users will be served another value.

For example, in the image below from the AB Tasty dashboard, the value that is fetched will be IOS in Scenario 1 and ANDROID in Scenario 2 so only the users matching this value will be exposed to the feature. 

This is extremely useful if you want to do gradual rollouts and testing in production and for generally more advanced use-cases.

Conclusion

For advanced use-cases, it would make sense to opt for a third party solution to help you manage and implement the different types of flags in your system.

These solutions offer features such as a UI for managing configuration with access control to limit who does what as well as audit logs to determine which changes were made by whom.

Therefore, sophisticated feature management solutions like AB Tasty are built to scale and include role-based and access controls to execute more complex use-cases.

Subscribe to
our Newsletter

bloc Newsletter EN

We will process and store your personal data to respond to send you communications as described in our  Privacy Policy.

Article

5min read

Top 10 Feature Flags Projects on GitHub

What are the top feature flags projects on GitHub? Let’s find out.

If you are into open-source software, GitHub is probably the go-to place to find interesting projects you can use for free and contribute to.

Feature flags tools are no exception. We have listed below the top 10 feature toggle repositories on github.com ranked by popularity.

If you want to explore alternatives that scale better and are suitable for more use cases, read our article about feature flag implementation journey where we answer the question: should I build or buy a feature flag platform.

For a comprehensive overview of what feature flags are, refer to our feature flagging guide.

1. Unleash/unleash

Unleash is the open-source feature management platform. It provides a great overview of all feature toggles/flags across all your applications and services. Unleash enables software teams all over the world to take full control on how they deploy new functionality to end users.

 

https://github.com/Unleash/unleash

2. Fetlife/rollout

Fast feature flags based on Redis.

https://github.com/fetlife/rollout

 

3. jnunemaker/flipper

Flipper gives you control over who has access to features in your app.

  • Enable or disable features for everyone, specific actors, groups of actors, a percentage of actors, or a percentage of time.
  • Configure your feature flags from the console or a web UI.
  • Regardless of what data store you are using, Flipper can performantly store your feature flags.
  • Use Flipper Cloud to cascade features from multiple environments, share settings with your team, control permissions, keep an audit history, and rollback.

https://github.com/jnunemaker/flipper

 

4. uber/piranha

Piranha is a tool to automatically refactor code related to stale flags. At a higher level, the input to the tool is the name of the flag and the expected behavior, after specifying a list of APIs related to flags in a properties file. Piranha will use these inputs to automatically refactor the code according to the expected behavior.

This repository contains four independent versions of Piranha, one for each of the four supported languages: Java, JavaScript, Objective-C and Swift.

https://github.com/uber/piranha

 

5. checkr/flagr

Flagr is an open source Go service that delivers the right experience to the right entity and monitors the impact. It provides feature flags, experimentation (A/B testing), and dynamic configuration. It has clear swagger REST APIs for flags management and flag evaluation.

https://github.com/checkr/flagr

 

6. markphelps/flipt

Flipt is an open source, on-prem feature flag application that allows you to run experiments across services in your environment. Flipt can be deployed within your existing infrastructure so that you don’t have to worry about your information being sent to a third party or the latency required to communicate across the internet.

Flipt supports use cases such as:

  • Simple on/off feature flags to toggle functionality in your applications
  • Rolling out features to a percentage of your customers
  • Using advanced segmentation to target and serve users based on custom properties that you define

https://github.com/markphelps/flipt

 

7. ff4j/ff4j

FF4j, is an implementation of the Feature Toggle pattern for Java. It provides a rich set of features:

  • Enable and disable features at runtime – no deployments.
  • Enable features not only with flag values but also drive access with roles and groups.
  • Implement custom predicates to evaluate if a feature is enabled.
  • Keep your code clean and readable: Avoid nested if statements but use annotations.
  • Each action (create, update, delete, toggles) can be traced and saved in the audit trail for troubleshooting.
  • Administrate FF4j (including features and properties) with the web UI.
  • Wide choice of databases technologies to store your features, properties and events.
  • (Distributed) Cache Evaluating predicates may put pressure on DB (high hit ratio).

https://github.com/ff4j/ff4j

 

8. togglz/togglz

Togglz is another implementation of the Feature Toggles pattern for Java.

  • Modular setup. Select exactly the components of the framework you want to use. Besides the main dependency, install specific integration modules if you are planning to integrate Togglz into a web application (Servlet environment) or if you are using CDI, Spring, Spring Boot, JSF.
  • Straight forward usage. Just call the isActive() method on the corresponding enum to check if a feature is active or not for the current user.
  • Admin console. Togglz comes with an embedded admin console that allows you to enable or disable features and edit the user list associated with every feature.
  • Activation strategies. They are responsible for deciding whether an enabled feature is active or not. Activation strategies can, for example, be used to activate features only for specific users, for specific client IPs or at a specified time.
  • Custom Strategies. Besides the built-in default strategies, it’s easy to add your own strategies. Togglz offers an extension point that allows you to implement a new strategy with only a single class.
  • Feature groups. To make sure you don’t get lost in all the different feature flags, Togglz allows you to define group for feature that are just used for a visual grouping in the admin console.

https://github.com/togglz/togglz

 

9. jason-roberts/FeatureToggle

Simple, reliable feature toggles in .NET

https://github.com/jason-roberts/FeatureToggle

 

10. tompave/fun_with_flags

FunWithFlags is an OTP application that provides a 2-level storage to save and retrieve feature flags, an Elixir API to toggle and query them, and a web dashboard as control panel.

It stores flag information in Redis or a relational DB (PostgreSQL or MySQL, with Ecto) for persistence and synchronization across different nodes, but it also maintains a local cache in an ETS table for fast lookups. When flags are added or toggled on a node, the other nodes are notified via PubSub and reload their local ETS caches

https://github.com/tompave/fun_with_flags