Understand the basics of feature flags in a DevOps approach

Feature flags are versatile and powerful tools for software developers. However, they can also benefit DevOps manifest teams.

Continuation of the article below

A feature flag allows code to run conditionally based on simple controls placed in the code itself. Developers use feature flags (also known as feature toggles, feature switches, feature bits, conditional features, and so on) to enable or disable portions of code during its development. This should make it easier to test newly implemented code without testing multiple versions. As part of operations, employees can optimize the behavior of software in production, with important features and functions being controlled by function flags. These flags are used to support various software options.

In its simplest form, a feature flag is little more than a simple variable defined as true or false. It enables or disables a piece of software code – usually a function or feature – that is enclosed in an “if-then” conditional statement that uses the feature flag variable.

This generic snippet of code shows the simplicity of this concept:

theFeatureFlag = TRUE …… if theFeatureFlag = TRUE, then {execute the code here ……}

In principle, developers, testers and IT operations managers can activate or deactivate new code without disrupting existing software and infrastructure.

Use cases for feature flags

Feature flags are popular in companies that have chosen the DevOps approach, as developers and operations have to work together to adapt and optimize software.

Developers can also use feature flags for design purposes, such as: B. for A / B tests. For example, programmers want to optimize and improve a service contained in a software product in order to improve the performance on certain devices. In this way you can start the existing or the new version, depending on the performance achieved with different hardware infrastructures.

Below is a general example of this type of use case:

theNewFeatureFlag = TRUE (or FALSE) …… if theNewFeatureFlag = TRUE, then {… execute the NEW code here ……} otherwise {… execute the OLD code instead ……}

There are static and dynamic feature flags. In the examples above, they are basically hard-coded in the software itself. This configuration is common in situations where IT administrators need to test new features or code that are unlikely to make their way into production. In cases where the conditional flag needs to be dynamic, developers can write separate configuration files in text or YAML format that contain the flag settings that the software opens and reads at startup.

In the event that the IT department wants to optimize the performance according to the devices used, dynamic conditional functionality is preferably used. Take the example of software that has to perform complex calculations. The microprocessor has to manage a large load that saturates its instructions. A GPU would speed up and improve performance significantly.

A feature flag can check the presence of the GPU and act accordingly to make the calculations faster and more efficient:

… run the code to verify the presence of a GPU

… Now automatically set the feature flag accordingly

if GPUpresent = TRUE then {

set theGPUisPresent = TRUE

}}

otherwise {

set theGPUisPresent = FALSE

}}

… The software does some common, boring work

… blah

… blah

… blah

… Then the software has to do its calculations

if theGPUisPresent = TRUE then {

… do the calculations with the GPU (in a simple way)

}}

otherwise {

… do the calculations with the CPU (or do it the hard way)

}}

Benefits of job labeling in a DevOps approach

It is clear that these conditional functions benefit software developers, but this is less obvious when it comes to Ops teams or business units.

Let’s look at five common ways feature flags can improve IT operations.

Simplify application delivery. Deploying and updating applications typically results in downtime. However, conditional functionality enables a software product to contain a variety of features and functions that can be intentionally enabled or disabled – even if they are only used for testing and validation. Ideally, this serves to reduce the number of software versions and to simplify the provision of such applications.

Facilitating the localization of software. Different regions set specific requirements for business operations and apply them to various factors. Function flags allow administrators to configure software for a wide variety of operating environments and customize configurations to meet specific user needs.

For example, suppose country A allows organizations to collect personal information such as date of birth, but country B prohibits it. A “country” feature flag allows the software to remove the date of birth from the data entry screens when the software is deployed in country B.

Conditional functions can also help determine the language to be used in software interfaces and in reports. Aside from this linguistic difference, processes such as patches, performance monitoring, and security reviews are standardized. Administrators follow the same processes for the software regardless of country.

Validate the production. Although enterprise software is thoroughly tested before it goes into production, it is nearly impossible for software developers and professional testers to validate all possible combinations of hardware, applications, and other infrastructure. and dependencies with data centers before a product goes into production. If a software update causes incompatibilities, the DevOps team can come back at any time. A conditional function can disable the new code and allow a rollback to the previous version. As a result, deployments are smoother and testing methods change, ideally to include large-scale experiments.

For example, the team creates a new complex algorithm to replace an existing one. Once the new algorithm is in production, unexpected or unusable results will be generated for a given data set. Ops can modify the software configuration file to revert to the previous algorithm and create a help ticket for developers and data scientists to troubleshoot issues.

Switch a workload or optimizations. All software uses a certain amount of computational resources, including CPU, memory, and network I / O. The software is designed to use advanced resources such as multiple CPUs, GPUs to handle demanding calculations, and large amounts of memory for parallelized calculations or memory bursts. Not all deployment goals can provide all of the computing resources that a software product may use. Some servers may be older or have fewer processors or less memory than others.

In collaboration with developers, IT administrators can use conditional functions to discover the resources available on a server and to configure the computing power of the software so that the server is not overloaded. Ideally, this can help maintain good software performance on a wide variety of target systems.

Include premium features. Feature flags can also be used for more commercial purposes. You can turn on or off advanced features that are included in free, paid, and premium trials of software. The parameter chosen can depend on the license chosen by a customer. It also simplifies deployment for operations, although licensing the software requires additional management.

Be careful though, these conditional functions act like they would in a rule engine. If not regulated, they can cause conflicts and completely block software or application service. No tool on the market offers advanced management functions for these feature flags. Very strict monitoring is required to avoid production problems.