In modern software development, the ability to decouple deployment from feature release has become a strategic necessity. Teams want to merge half-finished code without breaking the user experience, activate risky changes with a kill switch, or grant access to a new feature to only one beta customer. The first instinct is often to reach for platforms like LaunchDarkly, Flagsmith, or Split. But for a small team or an early-stage SaaS, building your own feature flags in about a hundred lines of code is not a compromise—it is a technology ownership decision that many founders must evaluate. Q2BSTUDIO, as a company specialized in custom software development, understands that every piece of infrastructure deserves a careful build-versus-buy analysis. In this article we explore why a homegrown flag system is sufficient for most early cases, when it is worth outsourcing, and how to implement it without relying on external services.
What do feature flags actually provide? Stripping away the marketing noise, a flag is simply a runtime switch that decides whether a block of code executes, without requiring a redeploy. This enables several workflows: decoupling deploy from release (ship dark code on Tuesday, enable it on Thursday), kill switches for risky changes (a new payment gateway wrapped in a flag can be turned off with a SQL query instead of a full rollback), gradual percentage rollouts (5%, 20%, 50%, 100% with stable samples), per-user or per-tenant targeting (enable a feature only for a beta tester), and trunk-based development (merge incomplete code into main because it is off by default). None of these inherently require an external vendor.
Nevertheless, young teams often sign up for a flag SaaS from day one. The reasons against are concrete. First, cost scales with the wrong metric: plans are priced on monthly active users (MAU)—exactly what a growing product wants to increase. You pay more as you succeed, for a capability you could express in a database table. Second, you introduce a network dependency in the hot path: every flag evaluation may need a remote call or an SDK that must initialize, stream updates, and stay in sync. If the vendor has an outage, you need fallback logic, and you end up writing the same code you would have written from scratch. Third, data residency and privacy: to target by user, the service needs to know identifiers, attributes, sometimes more. For a product with European users, that means another processor in your data flow, another DPA to sign, another surface to audit. Keeping flag evaluation inside your own Postgres sidesteps all of that. Finally, and most importantly, most premium features—audit logs, approval workflows, multivariate experiments, twelve-attribute segmentation, a polished UI—are overkill for a three-person team whose 'flag UI' can be a simple UPDATE feature_flags SET enabled = true WHERE key = 'new_checkout';. Buying before you need it is like paying for an office suite when you only need a notebook.
The minimal solution we propose consists of four elements: a Postgres table, a deterministic hash function, a rule evaluator, and an in-memory cache. The feature_flags table has columns such as key (text, primary key), enabled (boolean, master switch), rollout_percentage (integer between 0 and 100), enabled_tenants and disabled_tenants (text arrays for allow/block lists). The master switch is your kill switch: if false, the feature is off for everyone, no exceptions. The tenant lists let you force-enable or force-disable for specific customers, ignoring the percentage. The percentage is applied deterministically: not with Math.random()—which would make the same user see the feature on in one request and off in the next—but with a hash function based on FNV-1a that combines the flag name and the user identifier. Thus the same user, for the same flag, always gets the same result until you change the percentage. Additionally, we salt the hash with the flag key so that a user is not always in the same percentile across all flags: the unlucky cohort of the first rollout will not be the same for the second. The evaluator applies the rules in order: first the master switch; then the exclusion list (if the user is in disabled_tenants, turn off); then the inclusion list (if in enabled_tenants, turn on); and finally the deterministic percentage. If there is no identifier (anonymous user), it activates only if the percentage is 100. An unknown flag returns false, never throws an exception: a typo should not crash a request.
Performance is critical: we cannot query Postgres on every evaluation. Therefore we load all flags into an in-memory map at startup and refresh it every 30 seconds via a setInterval. The update is atomic: we build the new map and then swap the reference, so a reader never sees a half-built map. If the query fails, we keep the last valid snapshot. The consequence is that a change in the database takes up to 30 seconds to propagate to all instances. For a small team, that is still much faster than a rollback deploy. If you need sub-second propagation, you might consider a more complex system or buy the SaaS, but for most cases 30 seconds is perfectly acceptable. This design fits naturally into a multi-tenant SaaS architecture, where the tenant identifier is already used throughout the application. Q2BSTUDIO integrates cloud solutions on AWS and Azure that allow deploying this logic with high availability and auto-scaling.
When should you actually buy LaunchDarkly? When needs exceed what a hundred lines can offer. For example: when non-technical people (product managers, marketing) need to change flags without writing SQL; when you need a rich audit trail with approvals (regulated industries); when segmentation becomes complex (plan, country, signup date, etc.); when you need real-time propagation (under one second); or when you start running A/B experiments with statistical significance. In those cases, the SaaS is worth every euro. But for a startup still seeking product-market fit, building is the smart decision. Remember that feature flags are just one piece of the technology ecosystem: you also need AI for personalization, cybersecurity to protect data, BI and Power BI to analyze flag behavior, and AI agents to automate responses. Q2BSTUDIO offers services in all these areas, from artificial intelligence to cybersecurity and pentesting, helping teams build robust systems without unnecessary overhead.
In summary: feature flags are a powerful tool that do not require a monthly subscription for small teams. With about a hundred lines of code, a Postgres table, a deterministic hash, and an in-memory cache, you get kill switches, gradual rollouts, and tenant segmentation. When your organization grows and needs advanced features, you can always migrate to a specialized service. But do not pay upfront for problems you do not yet have. The build-versus-buy decision is strategic, and at Q2BSTUDIO we help companies take the right path, offering both custom applications and integrations with cloud platforms, AI, and cybersecurity. The knowledge is in your hands—and in your database.





