Cutting feature flag costs

Last updated:

|Edit this page|

We aim to be significantly cheaper than our competitors. In addition to our pay-as-you-go pricing, below are tips to reduce your feature flag costs.

Understanding your bill

Feature flags are charged based requests made to our /flags endpoint, which is used to evaluate a feature flag for a given user. They are not billed based on $feature_flag_called events, which are optional events sent for metrics tracking, not for actual feature flag evaluation.

The number of /flags requests and the number of $feature_flag_called events are not directly related.

Creating a billable usage dashboard

Want to know exactly what's driving your bill? Create a dashboard with the PostHog billable usage template to break down and analyze your usage across different events, SDK libraries, and products.

PostHog billable usage dashboard

This dashboard turns your billing usage into a live, interactive report — so you can create insights, spot spikes, and optimize how you're spending.

Estimating your bill manually (with math!)

Frontend SDKs

We make a request to fetch feature flags (using the /flags endpoint) when one of the below occurs:

  • The PostHog SDK is initialized
  • A user is identified
  • A user's properties are updated
  • You call posthog.reloadFeatureFlags() in your code

For the JavaScript web SDK, you can estimate how many feature flag requests you will make by doing the following:

  1. Check the networks tab in Chrome inspector tools for the number of /flags requests
  2. Find out your number of monthly page views
  3. Multiply your number of /flags requests by your monthly page views

For example, if on refresh, you see 2 /flags requests per pageview and you have ~150,000 pageviews, your monthly feature flag requests should be around ~300,000.

Backend SDKs

Without local evaluation

If you're not using local evaluation, a request to get feature flags is made every time you call posthog.get_feature_flag() on your backend. Your estimated usage will be however many times you are calling this code.

With local evaluation

If you're using local evaluation, each local evaluation request is equivalent to, and charged as, 10 feature flag requests. Local evaluation calls, by default, are made every 30 seconds. Assuming your server is constantly running and making 2 requests per minute, you will be charged 10 * 2 * 60 * 24 * 30 = 864,000 feature flag requests each month.

Note: This figure is for a single server and a single instance of PostHog. If you have multiple servers, PostHog instances, or a different poll duration, you need to multiply your estimates too.

Reducing client-side feature flag requests

In our JavaScript Web and React Native SDKs, you can reduce the cost of feature flags by reducing the number of requests your client makes to fetch feature flag values for your users.

You can do the following using the advanced configuration:

  1. Set advanced_disable_feature_flags_on_first_load to true. This stops automatically requesting feature flags whenever a page loads. This is useful when you're immediately calling posthog.identify() anyway, which requests flags again.

  2. Set advanced_disable_feature_flags to true. This stops PostHog automatically requesting feature flags. Instead, use bootstrapping to load flags exactly once.

  3. Set advanced_only_evaluate_survey_feature_flags to true. When enabled, only survey feature flags are evaluated. This disables frontend evaluation of feature flags but still allows you to use them in surveys.

Note

Use of advanced_disable_feature_flags will disable surveys for all users, as surveys rely on feature flags internally. You should use advanced_only_evaluate_survey_feature_flags instead if you use surveys.

Reducing local evaluation costs

If you're using local evaluation, your bill may be high because of too many requests to fetch feature flag definitions. By default, PostHog fetches these every 30 seconds.

Each request charges 10 credits, so assuming your server is constantly running and making 2 requests per minute (the default setting), this will charge 10 * 2 * 60 * 24 * 30 = 864,000 credits each month.

You can reduce this by increasing the feature flag polling interval when initializing PostHog. For example, every 5 minutes instead of every 30 seconds.

The drawback of this approach is that whenever you make an update to a feature flag using the PostHog UI, it takes 5 minutes (instead of 30 seconds) for that change to roll to your server.

Edge/Lambda environments

Do not use local evaluation in an edge or Lambda environment, as this initializes a PostHog instance on every call, which can raise your bill drastically. It's best to use regular flag evaluation instead.

Quota limiting

Like all PostHog products, you can set a billing limit for feature flags. When a project exceeds this limit, the /flags endpoint will return a quota_limited response like this:

JSON
{
"quota_limited": true,
"featureFlags": {}
}

In this case, SDKs will:

  1. Return the default value for the feature flag, like false for isFeatureEnabled() and null for getFeatureFlag()
  2. Include a quota_limited property in the response
  3. Log a warning message if debug mode is enabled

This ensures that your application continues to function even when feature flag quotas are exceeded, falling back to default behavior rather than failing.

Audit environments to catch unexpected /decide calls

Watch out for forgotten environments

Forgotten environments, like old demos, test apps, or staging servers, and other PostHog SDKs, can silently rack up costs. Even if they don't send events, they may still be polling and making /flags calls for feature flags, session replay, and surveys.

These environments often get overlooked, especially if they're not part of your main deployment flow.

To identify where PostHog is still running:

  1. Create a trends insight
  2. Choose a high-signal event that occurs across SDKs: like $feature_flag_called, $identify, or a common custom event
  3. Set the chart type to Table
  4. Breakdown by $lib, $lib_version, and experiment with breakdowns on $host, $device_name, and $app_version as these can clue you into what environments are running PostHog
  5. Set the time range to Last 30 days

This shows you every SDK, domain, and version currently making requests, so you can spot any forgotten environments.

If you find environments that don't need feature flags, replays, or surveys, disable them entirely using advanced_disable_feature_flags:

JavaScript
posthog.init('<ph_project_api_key>', {
advanced_disable_feature_flags: true // Disables feature flags, surveys, and session recording
})

See advanced configuration options for details.

Questions? Ask Max AI.

It's easier than reading through 659 pages of documentation

Community questions

Was this page useful?

Next article

Server-side local evaluation

Note: Local evaluation is only available in the Node , Ruby , Go , Python , C#/.NET , and PHP SDKs. Note: Do not use local evaluation in an edge / lambda environment, as this can slow down performance, and also raise your bill drastically. It's best to use regular flag evaluation instead. Evaluating feature flags requires making a request to PostHog for each flag. However, you can improve performance by evaluating flags locally. Instead of making a request for each flag, PostHog will…

Read next article