Skip to main content

Evaluation paths, request counts, and optimization strategies for fast flag evaluation

Last updated November 14, 2026

Performance

The fastest flag evaluation is one that makes no network request. Flaggr can evaluate in your process, from the flag's configuration, or remotely, on the data plane at https://api.flaggr.dev.

Evaluation Paths

PathNetwork per evaluationHow to get it
Local evaluationNone@flaggr/sdk with updateMode: 'stream' or bootstrap, or @flaggr/evaluator
SDK cache hitNone@flaggr/sdk in any mode, within cacheTtl (10 s by default) of the last evaluation with the same context
Remote evaluationOne round trip to the data plane@flaggr/sdk in poll mode with a cold cache, the Python SDK, the Go SDK with WithAPIURL("https://api.flaggr.dev"), OFREP providers, POST /api/flags/evaluate
Batch evaluationOne round trip for up to 100 flags@flaggr/sdk in batch mode or evaluateBatch, POST /api/flags/evaluate/batch
Fastest Path

For latency-sensitive paths, use @flaggr/sdk with updateMode: 'stream'. Once the stream has delivered the configuration, evaluations run in-process. Flags whose rules use exists, not_exists, in_cohort or not_in_cohort are still evaluated remotely.

Optimization Strategies

1. Use Local Evaluation

Local evaluation downloads the flag configuration and evaluates in-process:

import { createFlaggr } from '@flaggr/sdk'
 
const client = createFlaggr({
  serviceId: 'my-service',
  apiKey: 'fgr_your_token',
  environment: 'production',
  updateMode: 'stream', // configuration pushed over SSE, evaluated locally
})

In edge runtimes, where a stream can't stay open, fetch the configuration and evaluate it with @flaggr/evaluator; see Edge & Serverless.

2. Use Bulk Evaluation

Instead of N individual requests, evaluate many flags in a single call:

POST https://api.flaggr.dev/api/flags/evaluate/batch
{
  "serviceId": "web-app",
  "environment": "production",
  "flagKeys": ["flag-a", "flag-b", "flag-c"],
  "context": { "targetingKey": "user-123" }
}

This reduces N round trips to 1. The SDK's batch mode and evaluateBatch send these requests for you.

3. Enable Streaming

Instead of polling, let flag changes arrive as they happen:

client.setUpdateMode('stream')
client.onFlagChange('checkout-v2', (event) => render(event.newValue))

4. Bootstrap Server-Rendered Pages

For SSR and SSG, fetch the flag configuration on the server and pass it to the client with the bootstrap option, so the first render evaluates without a request. See Bootstrap (SSR).

5. Cache Configuration

Tune the cache TTL to your consistency requirements:

const client = createFlaggr({
  serviceId: 'web-app',
  cacheTtl: 30000, // 30s cache for less-critical flags
})
Note

Longer cache TTLs reduce API calls but delay flag change propagation. For real-time updates, use streaming instead of aggressive caching.

Connection Reuse

Every evaluation path above runs over HTTPS, and a client that keeps its connection to the data plane open skips the TLS handshake on later requests. Reuse one SDK client (or one HTTP client) per process instead of creating one per request.

Monitoring Performance

Flaggr records its own request and evaluation metrics in Prometheus format, for whoever operates the deployment:

# P95 request latency
histogram_quantile(0.95, sum(rate(flaggr_http_request_duration_seconds_bucket[5m])) by (le))
 
# Evaluation throughput
sum(rate(flaggr_evaluations_total[5m]))
 
# Cache hit rate (control plane)
sum(rate(flaggr_cache_operations_total{result="hit"}[5m]))
/ sum(rate(flaggr_cache_operations_total[5m]))

In your own application, the SDK's otelPlugin() and the onRequest plugin hook measure evaluations and requests from the client side; see TypeScript SDK.