Local feature-flag evaluation

I built an Amplitude SDK that cut API calls from 10 to 1 per request. Local checks took under 1 ms. It shipped with 100% test coverage and no breaking changes.

10 → 1
API calls / request
< 1 ms
decision latency
100%
test coverage
0
breaking changes
Role
Architect & lead engineer
Timeline
Aug 2024 - Mar 2025
Stack
TypeScript, Amplitude SDK, Node, Jest
Tags
Architecture, JS SDK

§Context

Every meaningful decision in our platform (pricing experiments, gated features, region rollouts) passes through a feature flag. We were evaluating each one remotely, which meant ten flags on a single request became ten round-trips. We spotted the cost when we looked at p99 latency.

§What I did

  • Replaced the remote-evaluation pattern with a local evaluator backed by a periodically refreshed rule set.
  • Built a drift detector that compares local vs. remote decisions on a sampled slice of live traffic, with Slack alerts on disagreement.
  • Wrote a flag-by-flag migration path so the change rolled out behind its own flag. Yes, feature-flagged feature flags.
  • Got the change to 100% test coverage and shipped with no API breaks for consumers.

§Outcome

Requests got faster, and on-call engineers got Slack alerts when evaluations disagreed. Two more teams adopted local evaluation for new flag work.