Feature Toggle, one step closer to continuous integration and continuous delivery
Back in the day, my team couldn't deploy a new software version to production immediately. We had to wait because testing hadn't finished. Or because a big feature wasn't production-ready. Or because our acceptance tester didn't have time to check the new version.
Releasing big functionalities had become a struggle. Issues and increasing feedback time hindered those big bang releases. Oh yes, we know: continuous delivery only exists in theory,:-). But then we started introducing feature toggles.
What is a feature toggle?
A feature toggle enables you to change system behavior while running in production without changing the code or deployment. A new feature is developed behind a toggle. This helps us to test and release a version which has some fragmentary features or to enable a larger feature step by step.
Here is an example:
for (File cbor : getFilesFromLocalDirectory()) {
if (isLsmForwardingEnabled()) { // CB Order Response file only forward to LSM if this toggle is enabled
forwardToLsm(cbor);
}
if (isProcessingEnabled()) { // PUR will only handle CB order response if this toggle is enabled
handle(cbor);
}
moveToHistoryFolder(cbor);
}
How does this help:
As feature toggles give us more control and flexibility over the features we are working on, this helps us:
In Development
- Focus on small parts which reduce complexity
- Shorter integration cycles which reduce feedback time
- Speed up the process of development and testing
In Testing
- Ability to logically split big functionality and test step by step
- Move to the next level of continuous integration and delivery by promoting small chunks
In Releasing
- Avoid big bang releases and promote small parts
- Implement some big functionality and enable that in production by phases
- To roll back or fall back a feature easily, without the need of having a release
Are we building everything around a toggle?
No, we're not. We wrap a feature around a toggle to make sure a master(latest version of service) is always in deployable state or simply because it is better to implement a feature in phases
What we learned:
It is a good approach to split big functionalities into smaller parts that each can be implemented phase by phase. In this way, we safely deploy to production and reduce problems.
The feature toggle approach helps us to test and release big functionalities continuously by phases.
What are the cons:
- Toggles introduce complexity: you have to implement, manage and maintain them.
- Toggle debt: there's the additional effort of removing the toggle once the feature is fully live.
Reference:
Looking for further details about Feature toggles, refer https://martinfowler.com/articles/feature-toggles.html