How to Use Feature Flags in DevOps: Four Use Cases for Developers
Tags: opensource, devops, development, programming
Published: 2024-01-10 18:30:00

If developers need to go through the typical DevOps process (branching, etc.) each time they want to test in production, it can be painful.

How good would it be if developers could simply toggle a switch on/off in production and test things out, such as a new bubble chat feature or dark mode, without relying on another team? This would free up developers and let the DevOps team focus on what they're good at, too.

Yes, that's where feature flags come in.

## So, what are feature flags?

Feature flags empower developers to enable or disable specific features within an application or service without modifying the codebase. It's like turning a switch on and off. With tools like [Flagsmith](https://www.flagsmith.com/?utm_source=dev&utm_medium=content&utm_campaign=devops&utm_id=pradumna), it becomes much easier to create and manage flags and get features on top of them.

You can also read my recent blog I've written on this topic, where I explain this further and cover how we can test in production with feature flags using Flagsmith.

{% embed https://dev.to/pradumnasaraf/testing-in-production-with-canary-deployments-a-how-to-guide-m4g %}

The tasks that we going to discuss below were never this easy for a developer to
perform—just by toggling a switch. Feature flags revolutionize the process, not by replacing DevOps professionals, but by simplifying once tedious tasks, making optimization much more straightforward. This, in turn, streamlines the overall software development life cycle (SDLC), enabling DevOps professionals to concentrate on their strengths. Additionally, these features align seamlessly with various DevOps practices.

### 1) Feature Toggles:

Feature flags let you toggle a feature on and off when needed, like showing a signup form for some days every month. You don’t need to redeploy code (or wait for other teams/branches to finish their work), you can just toggle the feature on/off.

In the Flagsmith Dashboard, you can create a Feature flag, and then you can turn it on and off according to your needs. There’s a how-to guide for the process in one of my previous blogs; click [here](https://dev.to/pradumnasaraf/testing-in-production-with-canary-deployments-a-how-to-guide-m4g) to check it out.

![Flagsmith Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cql8jvnemi9tvht0capr.png)

### 2) Scheduled Releases:
Scheduled releases were always a huge DevOps-centric thing; people had to write cron jobs for this. But with Flagsmith, you can perform a feature release from the UI. For example, if there is a holiday season and you want to enable some offer banner on the homepage at midnight on 25th Dec, this feature is a game-changer. (Scheduled releases also let you meet compliance/regulatory standards. Say you’re an insurance company and you can only release a certain feature during enrollment windows, you can schedule the release to meet those requirements.)

![Flagsmith Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/73nhn5chhd1jzwz703ll.png)

### 3) Canary Deployment:
Sometimes we want to reduce risk and validate new software by releasing it to a small percentage of users. With feature flags, we can adjust and control the percentage of people who can see the feature. 

Here, only 10% of people will be able to see the chat menu, and with time, we keep increasing until it's completely enabled for everyone. This gives us time to gain user feedback and make adjustments before rolling it out to the whole user base.

![Flagsmith Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1cvfl91yzkpj9fq0n9f0.png)

### 4) A/B Testing:
Sometimes the team is working on a feature, and before rolling it out in production, they want to test it. We can easily test it with the Dashboard by allowing only 50% of people to see the new UI and 50% to see the old one. If the response and feedback are good, and users like it, we can roll it out for all users.

![Flagsmith Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nfavv2nz0r9wy6zc39sk.png)

In a nutshell, using feature flags makes life easier for developers. It lets them control and test their software effortlessly. With the ability to turn features on and off, developers can make their work smoother and better.

And here's the cool part – there are open-source tools like Flagsmith! Check out the [repository](https://github.com/Flagsmith/Flagsmith) to see it in action. Don't forget to give it a star to show some love. Join the awesome [community](https://discord.gg/hFhxNtXzgm) for help, questions, and cool discussions.