# Tutorial on using Feature Flags in Java \[Complete Example\]

DevFeed: [Tutorial on using Feature Flags in Java \[Complete Example\]](<https://devfeed.tech/articles/tutorial-on-using-feature-flags-in-java-complete-example-24987.md>)

Original publisher: [Read original article](<https://codeahoy.com/2020/11/22/feature-flags-with-java/>)

Author: umer

Published: 2020-11-22T00:00:00Z

Content type: tutorial

Language: en

Sources: [Code Ahoy - Articles](<https://devfeed.tech/sources/code-ahoy-articles.md>)

Topics: [feature flags](<https://devfeed.tech/topics/feature-flags.md>), [Java](<https://devfeed.tech/topics/java.md>), [Spring Boot](<https://devfeed.tech/topics/spring-boot.md>), [Tutorial](<https://devfeed.tech/topics/tutorial.md>), [Back end](<https://devfeed.tech/topics/backend.md>), [API](<https://devfeed.tech/topics/api.md>), [Databases](<https://devfeed.tech/topics/databases.md>)

Tags: [agile](<https://devfeed.tech/tags/agile.md>), [api](<https://devfeed.tech/tags/api.md>), [backend](<https://devfeed.tech/tags/backend.md>), [database](<https://devfeed.tech/tags/database.md>), [development](<https://devfeed.tech/tags/development.md>), [feature-flags](<https://devfeed.tech/tags/feature-flags.md>), [java](<https://devfeed.tech/tags/java.md>), [software-development](<https://devfeed.tech/tags/software-development.md>), [spring](<https://devfeed.tech/tags/spring.md>), [spring-boot](<https://devfeed.tech/tags/spring-boot.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

## AI overview

This tutorial explains how feature flags let software teams control feature visibility, gradually roll out changes, test changes in production, and roll back without redeploying. It demonstrates using feature flags in Java with Spring Boot through a backend API example.

## Source excerpt

Note: Unlaunch, the feature flagging service referenced in this post, has been shut down. Links to it have been removed. Feature flags (or feature toggles) is a powerful technique used by modern software teams to manage the behavior of their code in production. Gone are the days when production releases happened occasionally and were a big event. These days, agile teams deliver changes to production continuously, sometimes releasing changes several times a day without any fanfare. Feature flags let teams release their changes to production and stay in full control over who gets to see the changes and when. Using feature flags, you can: deploy changes to production but keep them hidden from everyone but internal users. gradually roll out features to build confidence. if things don't look good (you discover errors), roll back instantly without any code changes to redeploys. test your changes into production. I've been using feature flags for the last 5 years and find them very useful in shipping changes quickly and confidently to millions of users, from infrastructure changes like DB upgrades to UI changes. In this post, we'll see how to use feature flags in Java using Spring Boot. Let's get started. Challenge Suppose you're a software developer working on a backend service: User Profile. There is an API that returns user information from the database, combining it with information retrieved from some other services and sources. One day, you were reviewing the performance of the API and noticed it is very slow and takes up to a second to return response. After some investigation and find the root cause. The delay is being introduced due to the way the service calls other services to get user's status, open orders and pending cancelations: the calls are being made sequentially, that is, one after the other. You think you can improve the performance by parallelizing the calls. In traditional software development, you'd create a new feature branch e.g. feature/JIRA-101-a