2026-09-15 · 9 min
Feature Flags in Production: LaunchDarkly vs Self-Hosted in 2026
Three months ago, our system took down a checkout flow for users in the BSD City area during a payment gateway migration. Not a crash — a misconfigured environment variable that affected only the new payment flow, which we had already enabled for 100% of users without any rollout mechanism. We fixed it in eight minutes, but those eight minutes cost real conversions. Feature flags would have let us roll back the new flow in seconds, from a dashboard, without a redeploy.
That incident pushed us to actually decide between LaunchDarkly and running our own infrastructure. This article is that decision, written out.
What “production-grade” actually means for feature flags
Most tutorials show you a boolean flag and if (flag.isEnabled("new-feature")). That works. But production-grade feature flag infrastructure requires more:
- Evaluation consistency: the same user always gets the same variant, even across multiple server instances
- SDK failsafe behavior: if the flag service goes down, your app still runs — with a defined default, not an exception
- Audit trail: who changed what flag, when, and from what state
- Progressive delivery: percentage rollouts tied to a user identifier, not random per-request
Both LaunchDarkly and well-configured Unleash can do all of this. The question is the operational cost of each.
LaunchDarkly: the managed option
LaunchDarkly’s Node.js SDK initialization is two lines that matter:
import LaunchDarkly from "@launchdarkly/node-server-sdk";
const ldClient = LaunchDarkly.init(process.env.LD_SDK_KEY!, {
// SDK downloads flag rules on startup, evaluates locally
// No network call per flag evaluation
diagnosticOptOut: true, // skip usage telemetry if you prefer
initialConnectionTimeout: 10, // seconds before giving up on first sync
});
await ldClient.waitForInitialization({ timeout: 10 });
Flag evaluation with a user context:
interface LDUser {
key: string; // required: stable user identifier
email?: string;
custom?: Record<string, string | number | boolean>;
}
const user: LDUser = {
key: req.user.id,
email: req.user.email,
custom: {
plan: req.user.plan, // "free" | "pro" | "enterprise"
region: req.user.region, // "ID-BT" for Banten province
},
};
const isNewCheckoutEnabled = await ldClient.variation(
"new-checkout-flow",
user,
false // default if SDK unavailable
);
The SDK holds an open Server-Sent Events connection to LaunchDarkly’s edge network and patches its local flag cache in real time. Flag evaluations are local hash computations — no outbound HTTP per evaluation.
What you pay for: LaunchDarkly’s pricing in 2026 starts at $10/month for hobby use, $200/month for 1,000 Monthly Active Users on the Starter plan, and scales quickly. For a B2C product with 50,000 MAU, you’re looking at roughly $1,000–$1,500/month before enterprise features. That is not nothing.
What you get: zero infrastructure to run, an excellent dashboard UI, built-in experimentation (A/B testing with statistical significance), Slack/PagerDuty integrations, and a 99.99% SLA backed by edge PoPs. The SDK failsafe is also battle-tested: if LD’s API goes down, your app evaluates the last cached state, never throws.
Self-hosted: Unleash
Unleash is the most mature open-source option. The Community Edition is genuinely capable — I’ve run it in production for two separate projects.
Docker Compose setup that actually works:
# docker-compose.yml
version: "3.8"
services:
unleash:
image: unleashorg/unleash-server:6.5
ports:
- "4242:4242"
environment:
DATABASE_URL: postgresql://unleash:password@db/unleash
INIT_ADMIN_API_TOKENS: "default:development.supersecret"
# Important: set this to your actual domain in production
UNLEASH_URL: "https://flags.yourdomain.com"
depends_on:
db:
condition: service_healthy
db:
image: postgres:16-alpine
environment:
POSTGRES_DB: unleash
POSTGRES_USER: unleash
POSTGRES_PASSWORD: password
volumes:
- unleash_pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U unleash"]
interval: 5s
timeout: 5s
retries: 5
volumes:
unleash_pgdata:
Node.js SDK usage:
import { initialize, isEnabled } from "unleash-client";
const unleash = initialize({
url: process.env.UNLEASH_URL + "/api",
appName: "payment-service",
customHeaders: {
Authorization: process.env.UNLEASH_API_TOKEN!,
},
// Polling interval — streaming is Enterprise-only in Unleash OSS
refreshInterval: 15, // seconds
metricsInterval: 60, // report usage metrics back to Unleash UI
});
await new Promise<void>((resolve) => unleash.on("ready", resolve));
// Evaluation with context
const context = {
userId: req.user.id,
properties: {
plan: req.user.plan,
region: req.user.region,
},
};
if (isEnabled("new-checkout-flow", context)) {
// new path
}
One thing that trips people up with Unleash OSS: streaming flag updates are an Enterprise feature. In Community Edition, clients poll on the refreshInterval. That 15-second default means a flag change takes up to 15 seconds to propagate. For a kill switch scenario — you need to turn something off right now — that delay matters. You can lower refreshInterval to 2–5 seconds, but then every SDK instance is hammering your Unleash server with HTTP requests every few seconds. Size your Postgres connection pool accordingly.
Flipt: the alternative worth knowing
Flipt is lighter than Unleash and designed with gRPC-first evaluation. If you’re running a service mesh with gRPC already, Flipt fits naturally. Its flag definitions can live in Git (YAML files), which means flag changes go through your normal PR process — a behavior that is either exactly what you want or completely wrong for your use case.
# flags/checkout.yml — committed to git
version: "1.4"
namespace: production
flags:
- key: new-checkout-flow
name: "New Checkout Flow"
enabled: true
variants:
- key: "on"
name: "Enabled"
rules:
- segment: beta-users
distributions:
- variant: "on"
rollout: 100
- segment: all-users
distributions:
- variant: "on"
rollout: 20 # 20% rollout for all others
Flipt is worth choosing if: you want flags in version control, your team already reviews infrastructure changes as PRs, and you don’t need a non-technical stakeholder to toggle flags from a dashboard.
It’s wrong for: product managers who need to manage flags without engineering involvement, or any org where flag changes need to happen faster than your PR merge time.
The actual cost comparison
Running Unleash in production is not free. You need:
- A Postgres instance (RDS db.t3.small is ~$25/month, or managed PG on Railway/Render at similar price)
- The Unleash server container with at least 512MB RAM
- Monitoring and alerts on the Unleash server itself
- Someone to handle upgrades and incident response
Conservatively: $50–100/month in infrastructure, plus engineering time for maintenance. For a small team, that maintenance cost in hours probably exceeds the LaunchDarkly bill if your MAU count is moderate.
The crossover point in my experience: if you have more than ~20,000 MAU or work in a regulated industry where data residency matters (all flag evaluation data must stay in your own infrastructure), self-hosted wins on cost. Below that threshold, LaunchDarkly’s managed service is worth the subscription.
The kill switch pattern you need regardless of choice
Whichever tool you use, implement a global kill switch as a wrapper — not scattered isEnabled() calls throughout the codebase:
// lib/feature-flags.ts
import type { LDClient } from "@launchdarkly/node-server-sdk";
export class FeatureFlags {
private static globalKillSwitch = false;
constructor(private readonly client: LDClient) {}
async evaluate(
flagKey: string,
userId: string,
defaultValue: boolean = false
): Promise<boolean> {
if (FeatureFlags.globalKillSwitch) {
return defaultValue;
}
try {
return await this.client.variation(flagKey, { key: userId }, defaultValue);
} catch (err) {
// Never let flag evaluation crash your app
console.error(`Flag evaluation failed for ${flagKey}:`, err);
return defaultValue;
}
}
static triggerGlobalKillSwitch(): void {
// Call this from your emergency runbook script
FeatureFlags.globalKillSwitch = true;
}
}
This gives you an out-of-band emergency stop that doesn’t depend on the flag service being available. Store globalKillSwitch state in Redis if you need it to survive process restarts — a simple SET flags:global_kill 1 with your deployment pipeline watching for it is enough.
What I’d actually do in 2026
Start with LaunchDarkly if your team is under 10 engineers and your MAU is under 25,000. The productivity gain from not operating the infrastructure is worth the spend at that scale.
Move to self-hosted Unleash when: you have a dedicated DevOps person, your MAU crosses into territory where LD’s pricing becomes painful, or you operate under OJK fintech licensing requirements where data residency is a hard constraint — flag evaluation data tied to user IDs is PII, and some auditors will ask where it’s processed.
Flipt only if your flags are long-lived configuration that belongs in version control, not for dynamic rollouts managed by product.
The worst outcome is the one we had before any of this: a boolean environment variable that someone has to SSH in to change, with no audit trail and no rollback faster than a full redeploy.
Ditulis oleh Reza Pradipta