Product Benefits Pricing Guides Docs About Contact us Try it out
Performance

PostHog Flag Cache Billing Tracking

PostHog flag cache billing tracking: measure local evaluation cache hits and flag request cost so feature flags stay fast and cheap.

· 3 min read

Feature flags look free until the invoice arrives. A busy backend that checks a flag on every request can make millions of calls, and nobody notices until the cost line jumps. Without tracking, you cannot tell whether a spike came from real growth, a retry loop or a missing cache.

On 13 November 2026, PostHog changed how it bills local evaluation. A request that returns a 304 response, meaning your cached flag definitions are still current, now counts as one flag request. Teams that poll for definitions often should see how that fits their usage.

The point is not the exact price. It is that polling behaviour now has a visible cost, and you should measure it.

Data Points to Track

Log these from your server code or a wrapper around the SDK:

  • flag_key: which flag was checked.
  • evaluation_mode: local or remote.
  • definition_fetch_status: 200, 304 or error.
  • poll_interval_seconds: how often the SDK checks for new definitions.
  • cache_age_seconds: how old the cached definitions were at check time.
  • evaluation_latency_ms: time to return a value.
  • fallback_used: true if the SDK fell back to a remote call.
  • service_name and sdk_version: to find the noisy service.
  • flag_request_count: daily total, for comparison with your bill.

Setup Steps

  1. Switch server-side checks to local evaluation where your flags allow it, so most checks happen in memory.
  2. Wrap flag calls in one helper that emits flag_evaluated with the properties above.
  3. Record the poll interval in configuration and send it with each event, so changes are visible later.
  4. Count 200 and 304 responses separately in your own logs.
  5. Chart daily flag_request_count by service_name, and set an alert for a jump of, say, 30 percent in a day.
  6. After any interval change, annotate the chart and watch the next three days.
  7. Compare the total with your usage page each month and write down any gap.

Actionable Insights

Polling too often. A high share of 304s means you are asking for definitions that have not changed. Lengthen the interval if your rollout speed allows it.

Fallback storms. A rising fallback_used rate shows local evaluation is failing, often because a flag uses a property the SDK cannot resolve locally.

One noisy service. Cost is rarely spread evenly. Find the service and fix it first.

Latency trade-off. A longer interval saves requests but delays rollouts and kill switches. Check how long a flag change takes to reach every service before you commit.

Stale caches. If cache_age_seconds grows during an outage, users may see an old flag state. Decide how much staleness is acceptable.

Common Mistakes to Avoid

Teams sometimes cut the poll interval to speed up rollouts and forget it is multiplied by every running instance. Fifty containers polling every few seconds is a very different load from one. Multiply before you change it. Another slip is checking a flag inside a loop, or per row, rather than once per request: evaluate once, store the result, and reuse it. Finally, do not delete flags that have finished rolling out only to save cost without checking code first, because a missing flag can fall back to a default you did not intend.