What is a kill switch in feature release management?
This is when feature flags are used as a kill switch in the process of software development to disable features whenever necessary.
Think of it as an emergency button that you can use when things go wrong and you need to act quickly to prevent your users accessing a broken feature.
Using feature flags, developers can turn off broken features while testing in production with the simple switch of a button.
Without the use of feature flags, developers would have to roll back the entire release, which is time-consuming and a complex process that requires a thorough analysis of the issue thereby delaying the release while attempting to find an appropriate solution.
What feature flags enable you to do is isolate the changes to a specific feature without implementing a complete rollback. Therefore, with feature flags, you can rest assured that every single one of your features is under control.
Afterward, when the buggy feature is fixed, it is just as easy to redeploy the feature you killed.
In that sense, kill switches are essential to safely test in production to deal with any features that go wrong quickly and efficiently.
Kill switch in continuous integration and continuous delivery (CI/CD)
One of the main challenges that developers face during the process of continuous integration is how to deal with incomplete features. On one side, you have a developer that has merged their changes into the shared mainline and is ready to be released while another developer has not yet completed their changes.
How can you maintain the basic principle of continuous integration which is integrating changes as frequently as possible into the trunk and enabling these changes to be released at any time through continuous delivery in this scenario? Is there a way to switch off parts of the code while still going ahead with the release?
Feature flags save the day
Features flags or feature toggles, in the form of kill switches would allow developers to keep part of the code switched off during release so users wouldn’t see the unfinished changes while completed features can be switched on for users.
So we have seen that feature flags are used as a kill switch during CI/CD processes but they also have different use cases as we will outline below.
Unfinished features
As mentioned above, one of the most important uses for kill switches is the ability to turn off unfinished features so as to prevent your users from accessing them before they’re ready.
Therefore, any changes that are taking too long to complete will not delay scheduled releases and developers for their part are subjected to less pressure to release their own changes to the code risking a too early release with broken features.
Testing in production
When you are testing in production to a small subset of users, such as during canary deployment, you obviously want the release to go on without a hitch. However, after all, you’ve chosen to test on a small group of users meaning there is a chance that you’re less than confident about the feature working as it should.
Should any issues arise, you can simply deactivate the troublesome feature without having to do a complete rollback. Instead, you can just immediately switch it off so users can no longer see it without jeopardizing other parts of your code.
This way, you can take the time needed to analyze the issue, fix it then release it once again to production without any time constraints.
Managing high load
Kill switches are a good way to lessen the load on systems. For example, if your site is experiencing unusually high traffic, turning off some features can help to lessen the load and stress on the database.
As an example, consider an e-commerce site on Black Friday. You don’t want your site crashing down on what is considered to be the most profitable days of the year. Using feature flags helps tackle the issue of dealing with such unexpected crashes.
Thus, developers can disable non-essential features for some or all users during high load or in case of outages. This would enable your team to keep serving your customers without disrupting their services and putting a damper on the user experience.
Mobile apps
Feature flags can also be used as kill switches if something goes wrong in your mobile app release and you want to quickly get your app to the last working version.
They are also effective during a high traffic load to disable certain features so your app can still function even if it’s not at maximum capacity. Developers would do this by putting certain features behind feature flags to switch off when necessary.
Takeaways
So, as we’ve seen, a kill switch is essential to enable you to switch off any broken or unused features without interfering with the code.
It is especially important when incidents occur during production giving you the power to quickly turn off a feature that could negatively impact your users and ruin the user experience.
Consequently, using feature flags this way would allow you to implement continuous integration and testing in production techniques and this is important to maintain an agile software development process.
With feature flagging, you are mitigating any risks by keeping your features tightly under your control with an instant kill switch, giving your team a greater piece of mind for any upcoming releases.