Feature Toggle

26
Feature toggle also feature switch, feature flag, feature flipper, Trunk based development

Transcript of Feature Toggle

Feature togglealso feature switch, feature flag, feature flipper,

Trunk based development

Feature Toggles vs

Feature Branches

• Decoupling dev / deploying from releasing

✓ No manual / auto merge, less regression

• Version sync between src, tests, config, deploy scripts

• Pipeline management and monitor

• No data, schema migration and fallback, restore between different branches on staging, pre-production env.

Complication

– LinkedIn senior VP for engineering Kevin Scott

“LinkedIn’s big switch to continuous deployment has been linked to very concrete and visible financial success,… the

move to continuous deployment was about solving concrete problems rather than spreading a doctrine.”

Examples

#contact.rb if feature? :live_chat

puts ‘<script src=“/assets/live-chat.js”></script>’end

if some_featuredo some feature thing

end

Release Toggle• a.k.a: Application configuration based Toggles • Using application configuration file (XML,

YAML or JSON) to switch ON or OFF selected features.

{ "feature1": {"displayed": false}, "feature2": {"displayed": true}, "feature3": {"displayed": false} }

• a.k.a: rule based toggle• selectively turn on feature for certain classes of user• use performance parameters like # of users,

average load time etc.

Business Toggle

✓ select users where friends.count > 1000 and set TIMELINE_FEATURE = ON

✓ set MINICART_FEATURE = OFF when live.users > 5,000

✓ set MINICART_FEATURE = OFF when loadTime > 5s

How it’s used• for avoiding branching and merging (reduce risk)

• experimenting such as A/B tests

• test new features in a live production

• dark launch, phased rollout

• demo stakeholders new features without staging server

• turning a resources heavy feature OFF in high load conditions

• easier to roll-back when a new feature misbehave

FB: GateKeeper

FB: GateKeeper/Airlock

CRUID Life-cycle• Development team create toggles when required

• Application read or expose toggled feature when they are switched ON

• Development team update toggled features when they are buggy

• A semi-automated process to destroy or remove toggles when job is done

- Remember that although simple conditionals are the easiest way to implement a toggle, you should use techniques like polymorphic substitution to minimize how many points the toggle is tested.

- Release toggles are a useful technique and lots of teams use them. However they should be your last choice when you're dealing with putting features into production. Your first choice should be to break the feature down so you can safely introduce parts of the feature into the product.

Feature Flags with Caution

• Decision object as constructor parameter

• Feature grouping and dependency

• Code duplication v.s. toggles #

• Require more coding skill and discipline

• Trunk is always in releasable status

✓ Test automation

Feature Flags with Caution

Feature Toggle Framework ListFeature Flags in Java

• Togglz, FF4J, Fitchy, Flip

Feature Flags in Python

• Gargoyle, Gutter

Feature Flags in Ruby and Ruby on Rails

• rollout, feature_flipper, flip

• setler, switches, fluidFeatures

Netflix OSS

• Archaius - polling framework

http://www.slideshare.net/jallspaw/10-deploys-per-day-dev-and-ops-cooperation-at-flickr

http://apptimize.com/blog/2015/03/how-facebook-feature-flagged-its-way-into-a-feature-article/

http://code.flickr.net/2009/12/02/flipping-out/

http://techblog.netflix.com/2013/08/deploying-netflix-api.html

http://continuousdelivery.com/2011/05/make-large-scale-changes-incrementally-with-branch-by-abstraction/

http://www.wired.com/2013/04/linkedin-software-revolution/

https://www.infoq.com/news/2016/02/featuretoggles

Reference