Lesson 2 of 9 · 26m
Evaluation Paths, Caching, and Failure Fallbacks
Design where and when flags evaluate, how values propagate, how caching behaves, and what the system does when the control plane fails.
Most flag outages are not caused by bad rules. They are caused by a fuzzy evaluation path. One service evaluates at request time, another at startup, the frontend caches for a week, and a worker uses whatever value existed when the job was enqueued. Then a launch looks nondeterministic and everybody blames the vendor. Determinism is a design property.
Decide when the decision is made
Evaluation timing changes semantics:
process boot stable, cheap, poor rollback granularity
request start current user context, predictable per request
operation boundary correct for long-running workflows
user interaction good UX, easy to flicker or leak
job enqueue durable behavior for async work
job execution current behavior, can split a workflow in halfFor multi-step workflows, pin the decision to the unit of work. If a purchase starts under the new orchestrator, capture and refund should know which path the order used. Store the decision with the order rather than re-evaluating a moving flag days later:
ALTER TABLE orders
ADD COLUMN payment_path TEXT NOT NULL DEFAULT 'legacy_gateway';Caching is part of correctness
Caching reduces latency and vendor dependency, but every cache needs a staleness budget. A five-second server cache is often fine. A thirty-day mobile cache is not a rollout mechanism; it is a museum.
{
"key": "search.v2-parser",
"value": true,
"variation": "ten-percent",
"evaluated_at": "2026-11-30T13:20:41Z",
"ttl_seconds": 30,
"reason": "percentage-rollout"
}Record the reason and version. During an incident, flag was on is much less useful than user matched rule 3 in rollout version 18 evaluated 41 seconds before the error.
Design the control-plane outage
Ask the uncomfortable question first: what happens when the flag service is unavailable? A sane SDK exposes explicit fallback behavior:
client = FlagClient(
api_key=settings.flags_key,
cache_ttl=timedelta(seconds=30),
bootstrap_file="/run/flags/bootstrap.json",
)
enabled = client.enabled("catalog.read-replicas", context, default=False)The last known good value is often better than a hardcoded default during a short outage. For first boot, a signed bootstrap file or environment snapshot can prevent a cold start from silently reverting production behavior.
Field notes
- Never re-evaluate a halfway-completed financial, provisioning, or migration workflow unless you have modeled mixed-path behavior.
- Log evaluation inputs at the same privacy boundary as other user attributes; context payloads can become accidental PII collection.
- Fallback tests belong in CI chaos or integration tests, not only in a vendor runbook.
- If the same flag is read in eight microservices, write down which service owns the side effect and which ones merely observe.
Was this lesson helpful?