You are on page 1of 4

CONTENTS

Getting Started ∙ What is a Feature Flag?

∙ The History of Feature Flags

∙ What Does a Feature Flag Look Like?

With Feature Flags ∙ Ways to Use Feature Flags

∙ Enhance Traditional Continuous Delivery

∙ End-to-End CI/CD Pipeline Flag Visibility

∙ Feature Flags and Technical Debt

∙ How to Get Started


WRITTEN BY NICK RENDALL
PRODUCT MARKETING MANAGER, CLOUDBEES

As any developer can tell you, deploying any code carries technical developed similar deployment capabilities as well. The feature
risk. Software might crash or bugs might emerge. Deploying features flag was philosophically fundamental to this development and set
carries additional user-related risk. Users might hate the new the standard for modern deployment maturity used by leading
features or run into account management issues. With traditional organizations everywhere today. Recently, feature flags have been
deployments, all of this risk is absorbed at once. Feature flags give used in tandem with continuous delivery (CD) tools to help forward-
developers the ability to separate these risks, dealing with one at a looking organizations bring features, rather than releases, to market
time. They can put the new code into production, see how that goes, more quickly.
and then turn on the features later once it’s clear the code is working
as expected. WHAT DOES A FEATURE FLAG
LOOK LIKE?
WHAT IS A FEATURE FLAG? The following is a simple feature flag in code used on an e-commerce
Simply put, a feature flag is a way to change a piece of software's site. This software displays a “Happy holidays!” greeting message
functionality without changing and re-deploying its code. Feature and an associated “see more holiday deals” call to action to a site
flags involve creating a powerful “if statement” surrounding some visitor when it is instructed to. The developer has a way to toggle
chunk of functionality in software (pockets of source code). this functionality on and off without re-deploying the code for every
holiday or across every instance where it should appear.
THE HISTORY OF FEATURE FLAGS
Leading Web 2.0 companies with platforms and services that must
maintain performance among high traffic levels led the way in
regard to developing and popularizing new deployment techniques.
Facebook, in particular, is known as a pioneer of feature flags and
for releasing massive amounts of code at scale. While building its
massive social network more than a decade ago, the company
realized that its uptime and scale requirements could not be met with
traditional site maintenance approaches. (A message saying the site
was down while they deployed version 3.0 was not going to cut it.)

Instead, Facebook just quietly rolled out a never-ending stream


of updates without fanfare. Day to day, the site changed in subtle
ways, adding and refining functionality. At the time, this was a
mean feat of engineering. Other tech titans such as Uber and Netflix

1
REFCARD | GETTING STARTED WITH FEATURE FLAGS

It would have a construct like this for the top of a page: performs best. In the example of an e-commerce site, a brand might
test whether a green or red “buy” button results in more transactions.
if(feature.isActive("holiday-greeting")) {
print("Happy holidays," + user.name + "!"); The brand would deploy both buttons, use a feature flag to split
its user base in half, and see which color performs the best. The
}
possibilities for production experiments are endless, and the results
can significantly improve your application. When used correctly,
And then perhaps something like this at the bottom:
experiments provide product owners and developers with a much
if(feature.isActive("holiday-greeting")) { shorter feedback loop with their end users, resulting in improved
printLink("Click to see more holiday deals",
customer acquisition and retention.
"~/holidayDeals");

} REMOVING RISK FROM MIGRATIONS


Feature flags provide a low-risk alternative to the forklift upgrade
of years past that often ended in fire drills. Rather than rewrite
WAYS TO USE FEATURE FLAGS
large swaths of code for a one-time migration that causes issues,
CANARY LAUNCHES
developers can use feature flags to start building calls to the new
Alluding to the “canary in the coal mine,” canary deployments are
service or database directly into the existing application. They can
when software developers release a new version of software to just
discreetly test the new connection at a low-risk time to see if it’s
a subset of users or systems. By enabling new software within just a
working. When it's time to completely migrate, the code will have
part of the user base, developers can monitor any problems that it
been in production for a while and flipping the switch is a non-event.
creates without causing major disruption. Also known as
“progressive delivery,” this lets organizations keep general customer IMPROVING DEVELOPER PRODUCTIVITY
trust high while freeing developers to focus on innovating and Feature branching has been a long-time continuous integration
delivering excellent new functionality to customers. practice that allows teams to work with their own copies of the
code and, in general, merge all changes less frequently. However,
TESTING IN PRODUCTION
long-lived feature branches can cause their own headaches as
Conventional wisdom has historically been that testing should be
changes to the trunk and additions from other branches can result
done prior to production. However, internal test environments can
in what developers call “merge hell.” Using feature flags, it is easier
never fully recreate production. Facebook, Netflix, and the other
for developers to add their branches back to the trunk — wrapped
Web 2.0 organizations previously mentioned all understood that
within a feature flag and toggled off — in order to create the best of
given their scale, they could not possibly recreate their production
both worlds for feature branching without the merge hell commonly
environments for testing purposes. As a result, they run QA in
associated with it. Also, as flags allow independent development
production. By using feature flags, their developers de-risk deploying
and deployment, developers no longer have to be on call to
functionality whose production behavior is unknown to them, which
deploy features once they are finished. This frees up more time for
results in faster releases.
development and improves developer satisfaction.

TURNING OFF FUNCTIONALITY WITH A KILL SWITCH Table 1: Types of feature flags
In the same way that organizations can increase the number of
CATEGORY LONGEVITY DYNAMISM
users who see a feature, they can also decrease that number to zero,
creating a kill switch. This capability comes in handy when a feature Release Days to weeks (until Changes with deployment or
the functionality is runtime configuration (turn
doesn’t behave as planned. Developers can roll back the change and
deployed) off in case of rollback
let life go back to normal for users. It’s also useful for sunsetting and requirement)
then decommissioning legacy features. Kill switches absorb much
Experiment Weeks to months Changes dynamically
of the risk, stress, and overhead from a release for developers as it’s (until the data is
simple to roll back a feature. sufficiently recorded)

Ops Months to years (until Changes with runtime


RUNNING EXPERIMENTS it's no longer needed) configuration or dynamically
Production experiments are another popular way of using feature
Permissioning Indefinite (usually Changes dynamically
flags. The most common example is an A/B test, through which an
long-lasting)
organization deploys two different versions of a feature to see which

2
REFCARD | GETTING STARTED WITH FEATURE FLAGS

ENHANCING TRADITIONAL across the greater CI/CD lifecycle. This scenario is a recipe for disaster

CONTINUOUS DELIVERY in larger organizations where there are many developers and new

Continuous delivery can be difficult to truly master in more complex features are being developed regularly. Feature flags can impact the

organizations. Feature flags provide guard rails for teams wanting entire CI/CD process, and development teams should be purposeful

to start or grow their current CD program. Feature flags can enable in how they incorporate them into their tools and processes.

a shift from full release to feature-level granularity, which keeps


Some enterprise feature flag management tools offer CI/CD tool
release teams on schedule and helps avoid large rollbacks due to
integration out of the box to expedite this process. Otherwise, teams
former feature dependencies within a release. Feature kill switches
can expect to spend ample development time building out flag
provide the safety of turning off any buggy features without having
visibility views into their current toolsets. Once visibility of flag status
to redeploy the entire release.
and approval flow across CI/CD is common across development,

Testing in production increases QA teams’ confidence that the operations, and shared services teams, feature development and

code will perform as intended in real environments. Flags also release can be expedited with the assurance that flags will not be

provide higher granularity of release to end users based on updated without the knowledge of all teams involved.

any of their characteristics in your system (e.g., email address,


geography, version), allowing for more targeted testing or rollout, FEATURE FLAGS & TECHNICAL DEBT
experimentation, and customization. Release teams can move One of the historical knocks on the use of feature flags is that they

beyond focusing on the moving bits between different target create technical debt. This is an understandable sentiment since, if

environments to focusing on growing customer value with feature implemented by hand, they can lead to massive, ad hoc tangles

flags in continuous delivery. of conditional logic in the codebase. And that can be downright
nasty. Technical debt is one of the reasons why it can make sense to
Table 2: Traditional CD vs. modern CD with feature flags consider adopting a third-party management system. These systems

TRADITIONAL CD MODERN CD WITH FEATURE FLAGS can actually save you from technical debt, even as your own home-
rolled solution may cause it. But even with such a system, you have
Focused on delivering Focused on delivering features
releases to be careful.

Emphasis on target Emphasis on customers


In general, codebases tend toward entropy — they tend to rot unless
environments
you actively curate them. It’s no different with your implementation
Emphasis on intensive pre- Greater shift to testing in production of feature flag management. Do your best to group toggle points
production testing
as close together as possible, rather than having features sprawl
Limited granularity of user User testing based on any criteria all over the application. Adhering to the SOLID principles will help
testing based on available available in the database
with this, as will keeping your code (and feature flag logic) DRY. And
criteria
make sure to ruthlessly cull outdated toggle points and routers and
"All or nothing" rollout or Features are decoupled from each other
to plan to retire your feature flags.
rollback of a release based within a release and can be rolled out or
on feature dependencies and rolled back independently
performance HOW TO GET STARTED
Deploying code to production while It may seem like turning on or off one little thing in an application
Business teams and
developers must work in the business determines feature launch is over-engineering, but consider the idea of application logging,
tandem to deploy a release to timing decouples developers from the
however. If a developer were brand new to programming or writing
production at the ideal time release process
some kind of toy implementation, it might actually be easier to just
use their language’s file API to dump some random text to a file than
STRIVE FOR END-TO-END CI/CD it would be to install and configure a full-blown logging framework.
PIPELINE FLAG VISIBILITY But how long would that last? Would they hold out until they had to
The complexity of feature flags only increases as usage grows consider log levels? Different styles of appender? Multi-threading?
across an organization, as does the importance of flag visibility and
Sooner or later, it would become more painful to keep rolling it
governance across teams and tools. Feature flag usage in silos exists
themselves than it would be to go back and use an established
when certain, select developers are aware of specific flags’ status, but
solution. The same goes for feature flag management. If a developer
there is no structure and process for visibility and decision making
or team is new to it and dabbling, then it makes sense to implement

3
REFCARD | GETTING STARTED WITH FEATURE FLAGS

it manually. They will develop an understanding of how it works and FEATURE FLAGS WILL BECOME
make better decisions later. But if they find themselves in over their STANDARD IN MOST ORGANIZATIONS
heads, remember that mature, third-party feature flag management While there are many considerations for adding feature flags into a
systems exist for a reason. software delivery lifecycle, the benefits of flagging most, if not all,
features are clear. As the methodology and platforms mature, feature
FEATURE FLAGS AT SCALE flags will become an integrated part of the software development
Many organizations start using feature flags with homegrown systems infrastructure, and there may be a time when every feature is
that their developers create. These can be effective for smaller teams released wrapped in a flag for maximum safety and velocity.
and companies. However, once a company is ready to scale their
feature flags across their organization and make them a staple of At the same time, organizations will move from “if” to “how” in

their continuous delivery efforts, they need to consider whether their regard to better automating and integrating flags into their strategy.

internal system will scale. Asking the following questions can help There is a maturity scale that should be considered for getting started

determine which approach is the best fit: with flags — from developing an internal system to most likely
choosing an external platform to manage flags and integrate with the
OVERHEAD greater SDLC.
How many hours a week am I willing to devote to maintaining my
If you are just getting started, it will be a journey, no question. But the
internal flagging system? Am I comfortable dedicating developer
benefits will be worth the effort.
hours to system maintenance and updates?

VISIBILITY AND GOVERNANCE


How will technical and non-technical users be able to see which
features are flagged, and when? How will I be able to ensure only
WRITTEN BY NICK RENDALL,
correct users can flag items at the correct time, and that those PRODUCT MARKETING MANAGER, CLOUDBEES
flags are retired appropriately?
Nick works on the Feature Flag team at
CloudBees where they are constantly looking
SECURITY AND DATA PRIVACY for ways to make developers’ releases safer
How will I ensure that only the right users have access to flags? How and faster, with as few headaches along the way as
possible. Previously, he spent time on the IT Ops side of the
do I create clear audit trails for my flags? How will I handle personally house at Hewlett Packard Enterprise and Micro Focus, until
identifiable information (PII) within my flagging system analytics? he realized devs have way more fun.
Conversely, would I be comfortable storing my customers’ PII on
vendors’ external platforms?

ANALYTICS
How will I ensure I'm getting feedback on my features accurately
and in real time? Do I want to maintain another analytics dashboard,
or do I want to integrate feature information into my current DZone, a Devada Media Property, is the resource software developers,
engineers, and architects turn to time and again to learn new skills, solve
dashboards? software development problems, and share their expertise. Every day,
hundreds of thousands of developers come to DZone to read about the latest
technologies, methodologies, and best practices. That makes DZone the ideal
DEVELOPER PRODUCTIVITY place for developer marketers to build product and brand awareness and
drive sales. DZone clients include some of the most innovative technology
Are my developers most productive using an internal system as-is, and tech-enabled companies in the world including Red Hat, Cloud Elements,
or would they benefit from using an external platform with reduced Sensu, and Sauce Labs.

maintenance and likely greater developer-focused features? Is


my current system as developer friendly as possible using new
Devada, Inc.
methodologies such as configuration as code? 600 Park Offices Drive
Suite 150
Research Triangle Park, NC 27709
As the number of feature flags used internally increases, the answers 888.678.0399 919.678.0300
to these questions become increasingly complex. In fact, in a recent Copyright © 2021 Devada, Inc. All rights reserved. No part of this publication
may be reproduced, stored in a retrieval system, or transmitted, in any form
study, 90 percent of developers surveyed said they would consider or by means of electronic, mechanical, photocopying, or otherwise, without
prior written permission of the publisher.
moving to an external system as the overhead and complexity grew
with their flag usage.

You might also like