The Art of Feature Flagging

Rate this content
Bookmark

Fed up with merge conflicts and system failures after a big release? Feature flags can be your lifesaver!


We strive to get new features to the hands of our users as fast as we sustainably can. Some features can take longer to develop and touch other parts of the system. If not handled with care, these kinds of features can result in merge conflicts that keep developers up all night, not to mention the dreaded system failures following a big release. Equipped with feature flags, we can avoid this nightmare and continuously deploy code changes safely.


This talk consists of practical tips on how to use feature flags as release toggles.

This talk has been presented at DevOps.js Conf 2021, check out the latest edition of this JavaScript Conference.

FAQ

Feature flagging is a software development technique used to enable or disable features in a codebase without deploying new code. This is achieved by using flags or toggles that control whether certain features are active, allowing developers to test and deploy features incrementally and safely.

Feature flagging allows developers to deploy code with new features turned off, so they can safely integrate and test the code in production without exposing it to all users. Once the feature is verified to work correctly, the flag can be turned on to activate the feature for all users, reducing the risk of system failures after big releases.

The benefits of CI/CD with feature flagging include the ability to continuously merge and deploy small increments of code changes, reducing the risk of large merge conflicts and deployment issues. Feature flagging also allows for safer experimentation and testing in production environments without affecting all users.

Feature flags can be set differently in various environments (e.g., development, UAT, QA, and production). For instance, a flag can be turned on in development and off in production, allowing developers to test new features in a controlled environment without affecting the live production system.

The process of implementing a feature flag involves introducing the flag in the code, writing tests for scenarios when the flag is on and off, deploying the code to different environments with the flag appropriately set, and finally, once the feature is ready for release, turning the flag on in production. After ensuring the feature works as expected, the old code and tests related to the flag being off can be removed.

Feature flagging improves automated testing by allowing developers to write tests for both scenarios when a feature flag is on and when it is off. This ensures that both the new feature and the existing functionality are tested thoroughly, reducing the risk of introducing bugs.

Yes, feature flagging is very versatile and can be used in both backend and frontend code, including web app front-end code and mobile app front-end code. This allows for consistent feature management across the entire software stack.

An example of using a feature flag in a web application is a digital comic website that initially uses a math randomizer to serve a random comic. Developers can introduce a feature flag to switch between the math randomizer and an AI randomizer based on the environment, allowing the AI randomizer to be tested in development without affecting production users.

Once a feature flagged code has been verified in production, the feature flag can be turned on for all users. Afterwards, the implementation code for when the flag is off, as well as the related tests, can be removed to clean up the codebase.

Feature flagging allows long-term features to be developed and integrated into the codebase incrementally. Developers can safely deploy partial implementations to production, test them in controlled environments, and gradually build out the feature without affecting the end users until it is fully complete and ready for release.

Dianing Yudono
Dianing Yudono
8 min
01 Jul, 2021

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Feature flagging is an effective practice in software development to prevent unexpected impacts of code changes. Virtuflex offers a solution for continuous integration and deployment, allowing developers to serve random comics with different randomizer options. Feature flags are used to control the behavior of AI systems during development, enabling gradual deployment and automated testing. Once a feature is complete and tested, the code and flag can be safely removed.

1. Introduction to Feature Flagging

Short description:

Hi, my name is Diani Yedono, and I've been developing software for over a decade. I would like to share one effective practice called feature flagging that I've been using to keep integrating and deploying my code. Sometimes changes to a code wouldn't affect any other part of the software system. However, even a little change can unexpectedly affect other parts. There are many processes that people use to ensure the software is protected from migrations introduced by any code change. One of the processes is to have long-lived feature branches.

Hi, my name is Diani Yedono, and I've been developing software for over a decade. I would like to share one effective practice called feature flagging that I've been using to keep integrating and deploying my code.

Let's start with thinking back in time. Can you remember that time when a system failure happened right after a big release? If you've never experienced that, I wish you don't ever have to because it's just awful. This comment shows a person asking another person to imagine they deployed a new version of their customer management system and 15 minutes later the online shop crashes.

Sometimes changes to a code wouldn't affect any other part of the software system. However, in many cases, even a little change can unexpectedly affect other parts. And that's quite normal. There are many processes that people use to ensure the software is protected from migrations introduced by any code change. One of the processes is to have long-lived feature branches. Each of the branches is extensively reviewed and tested before being merged. However, this can lead to another type of problem. This comment shows a developer who's trying to merge their branch into main. First, they pull the changes from main into their branch. Once they're happy, they're getting ready to merge their branch back into main. However, another developer has just merged a big chunk of change into main. Merging big changes can lead to merge conflict and that can keep developers up at night. And it's not a sustainable practice.

2. Introduction to Virtuflex

Short description:

Continuous integration is a popular practice in software development, but merging half-baked code can be challenging. Thankfully, Virtuflex offers a solution. This talk focuses on using Virtuflex for continuous integration and deployment. Let's explore an example web application that utilizes Virtuflex to serve random comics to users, with the ability to switch between a math randomizer and an AI-based randomizer.

These pains have led people to start practicing continuous integration, where developers continuously integrate their code changes into main, little by little and regularly. But what if the new feature takes rather long to develop? How can we merge half-baked code without affecting the users or consumers of the software?

Thankfully, Virtuflex can help us. Virtuflex has been used for many purposes, some of which are not part of this talk. So this talk is not about using Virtuflex for canary release, A-B testing, or Kailh switch. But this talk is about using Virtuflex for continuous integration, which is to continuously merge code changes into main or trunk, and continuous deployment, which is to continuously deploy code changes to production safely.

Now let's take a look at an example web application that is going to use Virtuflex. This is a web app that stores a collection of digital comics. It has one feature, which is to serve a random comic to the user. Initially, the website uses a math randomizer. Then it is decided to have a new feature and use an AI to serve a random comic to users. And this AI can serve the random comic depending on the weather, for example, or depending on what's trending in the world. I'm just making up some new features here. The randomizer needs to be changed to use AI. And it can take a while to do that.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Levelling up Monorepos with npm Workspaces
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Levelling up Monorepos with npm Workspaces
Top Content
NPM workspaces help manage multiple nested packages within a single top-level package, improving since the release of NPM CLI 7.0. You can easily add dependencies to workspaces and handle duplications. Running scripts and orchestration in a monorepo is made easier with NPM workspaces. The npm pkg command is useful for setting and retrieving keys and values from package.json files. NPM workspaces offer benefits compared to Lerna and future plans include better workspace linking and adding missing features.
Automating All the Code & Testing Things with GitHub Actions
React Advanced 2021React Advanced 2021
19 min
Automating All the Code & Testing Things with GitHub Actions
Top Content
We will learn how to automate code and testing with GitHub Actions, including linting, formatting, testing, and deployments. Automating deployments with scripts and Git hooks can help avoid mistakes. Popular CI-CD frameworks like Jenkins offer powerful orchestration but can be challenging to work with. GitHub Actions are flexible and approachable, allowing for environment setup, testing, deployment, and custom actions. A custom AppleTools Eyes GitHub action simplifies visual testing. Other examples include automating content reminders for sharing old content and tutorials.
Fine-tuning DevOps for People over Perfection
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Fine-tuning DevOps for People over Perfection
Top Content
DevOps is a journey that varies for each company, and remote work makes transformation challenging. Pull requests can be frustrating and slow, but success stories like Mateo Colia's company show the benefits of deploying every day. Challenges with tools and vulnerabilities require careful consideration and prioritization. Investing in documentation and people is important for efficient workflows and team growth. Trust is more important than excessive control when deploying to production.
Why is CI so Damn Slow?
DevOps.js Conf 2022DevOps.js Conf 2022
27 min
Why is CI so Damn Slow?
Slow CI has a negative impact on productivity and finances. Debugging CI workflows and tool slowness is even worse. Dependencies impact CI and waiting for NPM or YARN is frustrating. The ideal CI job involves native programs for static jobs and lightweight environments for dynamic jobs. Improving formatter performance and linting is a priority. Performance optimization and fast tools are essential for CI and developers using slower hardware.
The Zen of Yarn
DevOps.js Conf 2022DevOps.js Conf 2022
31 min
The Zen of Yarn
Let's talk about React and TypeScript, Yarn's philosophy and long-term relevance, stability and error handling in Yarn, Yarn's behavior and open source sustainability, investing in maintenance and future contributors, contributing to the JavaScript ecosystem, open-source contribution experience, maintaining naming consistency in large projects, version consistency and strictness in Yarn, and Yarn 4 experiments for performance improvement.
Atomic Deployment for JS Hipsters
DevOps.js Conf 2024DevOps.js Conf 2024
25 min
Atomic Deployment for JS Hipsters
This Talk discusses atomic deployment for JavaScript and TypeScript, focusing on automated deployment processes, Git hooks, and using hard links to copy changes. The speaker demonstrates setting up a bare repository, configuring deployment variables, and using the post-receive hook to push changes to production. They also cover environment setup, branch configuration, and the build process. The Talk concludes with tips on real use cases, webhooks, and wrapping the deployment process.

Workshops on related topic

Deploying React Native Apps in the Cloud
React Summit 2023React Summit 2023
88 min
Deploying React Native Apps in the Cloud
WorkshopFree
Cecelia Martinez
Cecelia Martinez
Deploying React Native apps manually on a local machine can be complex. The differences between Android and iOS require developers to use specific tools and processes for each platform, including hardware requirements for iOS. Manual deployments also make it difficult to manage signing credentials, environment configurations, track releases, and to collaborate as a team.
Appflow is the cloud mobile DevOps platform built by Ionic. Using a service like Appflow to build React Native apps not only provides access to powerful computing resources, it can simplify the deployment process by providing a centralized environment for managing and distributing your app to multiple platforms. This can save time and resources, enable collaboration, as well as improve the overall reliability and scalability of an app.
In this workshop, you’ll deploy a React Native application for delivery to Android and iOS test devices using Appflow. You’ll also learn the steps for publishing to Google Play and Apple App Stores. No previous experience with deploying native applications is required, and you’ll come away with a deeper understanding of the mobile deployment process and best practices for how to use a cloud mobile DevOps platform to ship quickly at scale.
MERN Stack Application Deployment in Kubernetes
DevOps.js Conf 2022DevOps.js Conf 2022
152 min
MERN Stack Application Deployment in Kubernetes
Workshop
Joel Lord
Joel Lord
Deploying and managing JavaScript applications in Kubernetes can get tricky. Especially when a database also has to be part of the deployment. MongoDB Atlas has made developers' lives much easier, however, how do you take a SaaS product and integrate it with your existing Kubernetes cluster? This is where the MongoDB Atlas Operator comes into play. In this workshop, the attendees will learn about how to create a MERN (MongoDB, Express, React, Node.js) application locally, and how to deploy everything into a Kubernetes cluster with the Atlas Operator.
Azure Static Web Apps (SWA) with Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
13 min
Azure Static Web Apps (SWA) with Azure DevOps
WorkshopFree
Juarez Barbosa Junior
Juarez Barbosa Junior
Azure Static Web Apps were launched earlier in 2021, and out of the box, they could integrate your existing repository and deploy your Static Web App from Azure DevOps. This workshop demonstrates how to publish an Azure Static Web App with Azure DevOps.
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
163 min
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
Workshop
Alex Korzhikov
Andrew Reddikh
2 authors
The workshop gives a practical perspective of key principles needed to develop, build, and maintain a set of microservices in the Node.js stack. It covers specifics of creating isolated TypeScript services using the monorepo approach with lerna and yarn workspaces. The workshop includes an overview and a live exercise to create cloud environment with Pulumi framework and Azure services. The sessions fits the best developers who want to learn and practice build and deploy techniques using Azure stack and Pulumi for Node.js.