Scrivio Interview library
ScenarioFoundations6 min read · updated 12 November 2026

Your team needs a feature-flag system for a Spring Boot service. A teammate wants to write one in a day using a database table. What questions would you raise before agreeing?

Before agreeing, we should ask which features are really needed (per-user targeting, percentage rollouts, audit history, a UI for non-engineers), who will maintain the system and handle its outages, and how flag changes reach every instance quickly and safely through caching and refresh. We should compare the idea with open-source and hosted tools and the OpenFeature standard, which gives a common Java API. A simple table can be fine for a handful of on/off flags, as long as we write down its limits.

Why this question is asked

Feature flags look trivial: an if statement and a boolean in a table. That is exactly why teams build them in a day and then spend months adding targeting, audits and caching. Interviewers ask this as a build versus buy scenario to see whether we can ask the questions that expose the hidden scope, without dismissing a teammate's idea. In this answer, we will recap what feature flags do, go through the questions on features, ownership and delivery, compare with existing tools and OpenFeature, and see when a simple table is the right answer.

1A Quick Recap of Feature Flags

A feature flag is a switch that turns behaviour on or off at runtime without a deployment. Teams use flags to release code dark and enable it later, to roll a feature out to 5 percent of users before everyone, to give a kill switch for a risky integration, or to run experiments. The code looks simple.

Java
if (flags.isEnabled("new-checkout", userId)) {
return newCheckout.handle(cart); // only for users the flag targets
}
return oldCheckout.handle(cart);

Notice the userId argument. The moment a flag depends on who is asking, the system behind isEnabled() is no longer a boolean lookup; it is a rules engine. That is the first thing to clarify with our teammate.

2Question 1: Which Features Do We Actually Need?

We ask what the flags will be used for in the next year, not just this week. Simple on/off flags for releases need almost nothing. Per-user or per-tenant targeting needs rules. Percentage rollouts need consistent bucketing, so a user who saw the new checkout keeps seeing it, usually by hashing the user id. Audit history matters when a flag change causes an incident and someone asks who changed what and when. And if product managers or support staff should flip flags, they need a safe UI with permissions, not SQL access.

Each of these is a small project. A one-day build covers the first; the others can easily add up to weeks, plus the tests that make sure targeting rules are evaluated correctly.

3Question 2: Who Maintains It and Handles Its Outages?

Once flags control checkout, the flag system is in the critical path. If the flag table is unreachable, what does isEnabled() return? A sensible default must be defined per flag, and the code must not throw. Someone must also clean up old flags, because a codebase with 300 stale flags is hard to reason about. And when the teammate who built it moves to another team, who owns it?

These questions are not objections; they are the real cost of building. A hosted service charges money for exactly this ownership, so we should know what we would be taking on.

4Question 3: How Do Flag Changes Reach Every Instance?

Our service runs on, say, 12 instances. If every isEnabled() call queries the database, a busy endpoint adds thousands of queries per second. So we cache flags in memory and refresh them, which raises the delivery question: how long until a change reaches all instances, and what happens in between?

Java
@Component
class FlagCache {
private volatile Map<String, Boolean> flags = Map.of();
@Scheduled(fixedDelay = 30_000) // refresh every 30 s (needs @EnableScheduling)
void refresh() {
try {
flags = repository.loadAll(); // a fresh, immutable map
} catch (DataAccessException e) {
log.warn("flag refresh failed, keeping the last values");
}
}
boolean isEnabled(String name) {
return flags.getOrDefault(name, false); // unknown flag: off
}
}
// a kill switch flipped at 10:00:00 takes effect by about 10:00:30 on every instance
Step throughHow a flag change reaches the instances
AdminFlag tableInstance 1Instance 2
set new-checkout = off
refresh after up to 30 s
new-checkout = off
refresh, a few seconds later
new-checkout = off

5 messages in order. Play them, or step through them one at a time.

Between the change and the last refresh, instances can give different answers.

Notice the trade-off: a 30-second refresh means a kill switch is not instant, and instances may disagree for up to 30 seconds. Faster delivery needs push, for example streaming updates, which hosted tools provide out of the box. Notice also that a failed refresh keeps the last known values instead of turning every flag off.

5Comparing With Existing Tools and OpenFeature

There are mature open-source flag servers and hosted flag services with Java SDKs, targeting, percentage rollouts, audit logs, UIs and streaming updates. OpenFeature is a vendor-neutral standard, hosted by the Cloud Native Computing Foundation, that defines a common API for evaluating flags, with a Java SDK and providers for many backends. Coding against OpenFeature means our application code does not depend on one vendor, and we could even start with a simple provider of our own and switch later.

Java
Client client = OpenFeatureAPI.getInstance().getClient();
boolean on = client.getBooleanValue("new-checkout", false,
new ImmutableContext(userId)); // the provider behind it can be swapped

Check the OpenFeature Java SDK version you use for the exact class names. The point for the discussion is that the question is no longer 'build or buy the whole thing' but 'which provider sits behind a standard API'.

6When a Simple Table Is Enough

Sometimes the teammate is right. If the service needs five on/off release flags, changed by engineers, where a 30-second delay is fine, a table with a cached reader is a reasonable answer and may take a day. What matters is writing down the limits in a short ADR: no per-user targeting, no audit beyond database logs, changes take up to 30 seconds, the team owns it, and flags are deleted after release. We also agree the trigger for moving to a real tool, such as 'the first time we need a percentage rollout or a non-engineer must change a flag'. Coding against an OpenFeature-style interface from the start keeps that move cheap.

7Follow-up questions

What is the risk of letting flags accumulate?

Every flag doubles the number of code paths in principle, so old flags make code harder to read and test, and a forgotten flag can be flipped by accident. Give every flag an owner and an expected removal date, and remove release flags soon after the feature is fully rolled out.

How do you make percentage rollouts consistent for a user?

Hash the user id together with the flag name and map the result to a number from 0 to 99; the user is in the rollout if the number is below the percentage. The same user always gets the same bucket, and including the flag name stops the same users being first for every feature.

Should flag evaluation ever call the network on each request?

Rarely. Evaluations should be in memory, with flag definitions refreshed or streamed in the background. A network call per evaluation adds latency and makes the flag system a new point of failure for every request.

8Conclusion

In this answer, we saw that a one-day database flag table hides a lot of scope. Before agreeing, we ask which features are needed (targeting, percentage rollouts, audit, a UI), who maintains the system and handles its outages, and how changes reach every instance through caching and refresh. We compare with open-source and hosted tools and the OpenFeature standard, and accept a simple table when the needs are simple, as long as its limits are written down.

What to say in the interviewAbout 80 seconds aloud

Open with

I would not say no, but I would ask a few questions first. What do we actually need: just on/off release flags, or per-user targeting, percentage rollouts, an audit trail of who changed what, and a UI so product or support can flip flags?

Then, if they want more

Each of those is real work, and percentage rollouts need consistent bucketing by hashing the user id. Second, who owns it? Once a flag guards checkout, the flag system is in the critical path, so we need safe defaults when the table is unreachable, someone to clean up old flags, and someone on call.

Third, delivery: with 12 instances we cannot query the database on every check, so we cache and refresh, say every 30 seconds, which means a kill switch is not instant and instances can disagree for a moment.

Then I would compare with existing open-source and hosted tools, and suggest coding against OpenFeature, the vendor-neutral flag API with a Java SDK, so the backend can be swapped later.

If we really only need a handful of engineer-controlled on/off flags, a table with a cached reader is fine, but I would write the limits in a short ADR and agree what would trigger moving to a proper tool.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your team needs a feature-flag system for a Spring Boot service. A teammate wants to...": https://scrivio-interview-library.netlify.app/architecture/architecture-decisions/e6e2358d62/