Why This Matters at Engineering Leadership Scale
A single API request in a modern platform can evaluate 10 to 20 feature flags across canary rollouts, Strangler-Fig routes, and kill-switches. Making synchronous remote RPC calls per flag check adds 50ms to 150ms of latency and turns your flag service into a Tier-0 single point of failure that takes down every customer when it hiccups.
Engineering leaders invert the model: evaluate 100% locally in SDK RAM in <0.05ms and treat the central control plane strictly as an asynchronous signed-ruleset publisher.
Core Mental Model & Architecture
Anchor the architecture in concrete evaluation, payload, and telemetry math:
- Throughput & SLO: 100,000 evaluations/sec (~8.6B/day),
<1mslatency (actual local RAM eval<0.05ms), zero SPOF if the control plane goes offline. - Ruleset Size Math: 500 to 1,000 active flags * ~500 bytes JSON = ~250 KB to 500 KB total (~60 KB gzipped) - easily held in every app pod's RAM.
- Telemetry Math: Instead of emitting 100k HTTP events/sec, SDKs count
(flag_key, variation)locally in memory and flush compact 2 KB rollups every 30 seconds, slashing telemetry bandwidth by 99.9%.
| Evaluation Pattern | Eval Latency | Control Plane Outage Impact | Fleet Cost | Best Fit |
|---|---|---|---|---|
Remote RPC (GET /eval) | 5ms to 25ms | Catastrophic Tier-0 SPOF | High (100k QPS fleet) | Anti-pattern at scale |
| Local Sidecar / Relay | 0.5ms to 2ms | Survives control-plane outage | Low | Legacy apps or huge targeting lists |
| Local RAM SDK + CDN + SSE Push (Chosen) | <0.05ms | Zero impact (RAM + disk fallback) | Minimal (S3/CDN + SSE) | High-throughput SaaS & mobile |
Step-by-Step Implementation Tutorial
1. Architect Control Plane, CDN Distribution, and Local SDKs
Decouple low-QPS flag writes from high-QPS evaluations via Ed25519-signed snapshots and compact SSE deltas.
CONTROL PLANE: Admin UI/Terraform -> Postgres -> Compiler:
1. Sign active ruleset JSON (<500 KB gzipped, Ed25519) -> S3 + CloudFront CDN (ETag)
2. Broadcast <1 KB delta over SSE Edge Fanout (<1.5s kill-switch)
DATA PLANE (100k+ Evals/sec, ZERO Hot-Path Network Calls):
SDK Boot -> Signed CDN snapshot (fallback: local disk cache) + persistent SSE stream (60s poll backup)
Hot Path (`isEnabled(key, ctx)`): Local RAM rule check -> `murmurhash3(key:salt:userId) % 100` (<0.05ms)2. Implement Deterministic Salted Local Evaluation
Adding a unique salt per flag prevents correlated rollouts so the exact same 5% of users are not placed into every beta simultaneously.
interface FlagDef {
key: string;
salt: string;
enabled: boolean;
rules: Array<{ attr: "tenant_id" | "plan" | "region"; values: string[]; variation: boolean }>;
rolloutPct: number; // 0..100
defaultVar: boolean;
}
interface EvalCtx {
userId: string;
tenant_id: string;
plan: string;
region: string;
}
function deterministicBucket(seed: string): number {
let h = 0x811c9dc5;
for (let i = 0; i < seed.length; i++) {
h ^= seed.charCodeAt(i);
h = Math.imul(h, 0x01000193);
}
return (h >>> 0) % 100;
}
export function evalFlagLocal(flag: FlagDef | undefined, ctx: EvalCtx): boolean {
if (!flag || !flag.enabled) return flag?.defaultVar ?? false;
for (const r of flag.rules) {
if (r.values.includes(ctx[r.attr])) return r.variation;
}
if (flag.rolloutPct <= 0) return false;
if (flag.rolloutPct >= 100) return true;
return deterministicBucket(`${flag.key}:${flag.salt}:${ctx.userId}`) < flag.rolloutPct;
}3. Handle the Minute-25 Curveball: 250k-User Segment Bloat + Sub-2s Global Kill-Switch
"An account manager uploads 250,000 explicit user_ids (bloating snapshots to 15 MB), AND a broken checkout flag needs a guaranteed global kill-switch in <2 seconds."
- Preventing Snapshot Bloat: Cap inline targeting lists at 1,000 IDs at the control plane. For massive cohorts, stamp the cohort attribute into the user's JWT (
cohort: "vip_beta") or route huge server-side segments through compact Bloom filters / a Redis-backed sidecar relay so global SDK snapshots stay strictly<500 KB. - Sub-2-Second Global Kill-Switch: Toggling a flag immediately publishes a
<1 KBsigned delta ({"key":"new-checkout","enabled":false,"ver":9421}) over horizontally scaled SSE edge gateways. Connected SDKs swap the in-memory pointer atomically within 500ms to 1.5s globally.
4. Split Multi-Squad Ownership
- Control Plane & Edge Distribution Squad (5 engineers): Owns Admin UI/Terraform, Postgres flag store, Ed25519 signing, S3/CDN snapshots, and SSE edge fanout.
- SDK & Experimentation Squad (5 engineers): Owns multi-language local SDKs (Go/TS/Python/Mobile), cross-language hash parity CI vectors, aggregated telemetry, and stale-flag cleanup automation.
Worked Production Scenario: Before vs. After
A multi-squad SaaS org previously ran a synchronous gRPC flag microservice handling 85,000 checks/sec. Flag RPCs added 18ms per service hop, and a 12-minute flag-service bug caused a full platform SEV1 cascade. Switching to signed CDN snapshots, SSE deltas, and local RAM SDK evaluation cut latency 550x and slashed infra cost 88%.
| Metric | Before (Sync gRPC Flag Service) | After (Local RAM SDK + CDN + SSE) | Net Impact |
|---|---|---|---|
| Evaluation p99 Latency | 22ms | 0.04ms (local RAM) | 550x faster |
| Control Plane Outage Impact | Full platform SEV1 | Zero impact (RAM + disk cache) | Zero SPOF risk |
| Monthly Flag Infra Cost | $9,200 / month (140 pods) | $1,100 / month (CDN + SSE) | -88% compute cost |
| Kill-Switch Propagation | Instant (while alive) | 1.1s p95 (SSE delta) | Fast & resilient rollback |
Common Failure Modes & Anti-Patterns
1. Cross-Language Hash Drift Between Backend and Frontend
The trap: Go and JavaScript hash user_id differently, enabling a UI flag on the browser while rejecting requests on the backend.
The structural fix: Run a single shared golden test vector file (1,000 (key, salt, user_id) -> expected_bucket fixtures) in CI across every SDK language.
2. Permanent Stale Flag Debt
The trap: Hundreds of shipped 100% flags linger in code for years, creating untestable branch mazes and bloated snapshots.
The structural fix: Require owner_team + expiry_date (60d default) on rollout flags and auto-file cleanup tickets 14 days after reaching 100%.
3. Leaking Internal Targeting Rules to Browser Clients
The trap: Shipping full server-side JSON snapshots (containing unreleased enterprise client names) straight to public browser SDKs. The structural fix: Separate server SDK snapshots from client endpoints where an edge worker evaluates context once at session boot and returns only resolved booleans for that user.
How to Handle Pushback in the Room
Product Engineer: "Doesn't async SSE evaluation mean two pods can disagree for 1 second when I flip a flag?"
Calm Executive Response: "Yes - you trade a 1-second convergence window for 550x lower latency and complete immunity to control-plane outages. For workflows requiring strict consistency across chained hops, we pass the evaluated variation once in the request context header."
VP of Engineering: "Should we build this platform in-house or buy LaunchDarkly / Statsig?"
Calm Executive Response: "Unless feature flagging is our core product, buying a mature local-SDK vendor (or self-hosting Unleash) saves 10 engineers of maintenance. Wrapping it behind the standard OpenFeature SDK gives us zero vendor lock-in while keeping squads focused on revenue features."
Key Takeaways & This Week's Action Rep
- Evaluate 100% in local RAM: Push signed
<500 KBsnapshots via S3/CDN + SSE deltas for<0.05mschecks and zero SPOF. - Salt deterministic hashes and test cross-language parity: Guarantee identical sticky cohorts across backend and frontend SDKs.
- Protect snapshots from segment bloat and client leaks: Keep large ID lists out of global JSON and evaluate browser flags at the edge.
- Standardize on OpenFeature: Avoid vendor lock-in whether you build or buy.
- This Week's Action Rep: Verify whether a feature-flag control-plane outage can crash your production APIs today, and delete at least 3 stale rollout flags sitting at 100% for >30 days.