On this page

Local evaluation

Local evaluation runs evaluation logic in the SDK. This approach avoids the network request that remote evaluation makes for each user. Amplitude engineers sub-millisecond evaluation for latency-sensitive systems that need to perform at scale.

Targeting capabilities

Local evaluation happens outside of Amplitude, so it doesn't support advanced targeting and identity resolution from Amplitude Analytics. Local evaluation does support consistent bucketing with target segments, which is often enough.

Client-side local evaluation

Client-side local evaluation includes all targeting data in the flag configuration that loads on the client. For example, if you target a specific user by their email, all clients can see that email, regardless of user.

Cohort targeting

Server-side SDKs can target cohorts when you configure them to do so. Local evaluation cohorts can target only User IDs.

Implementation

Local evaluation is evaluation. It's a function that takes a user and a flag as input and outputs a variant.

Diagram describing the local evaluation workflow.

On startup, the SDK loads flag configuration updates from the server and stores them in memory for access before each evaluation. After startup, the SDK polls the server for flag configuration updates.

Edge evaluation

The local evaluation Node.js SDK can run in edge workers or functions that support JavaScript and a distributed store. Contact your representative or email experiment@amplitude.com to learn more.

Exposure and assignment tracking

Local evaluation tracks assignment differently than remote evaluation, which automatically tracks exposure events. With local evaluation:

  • Client-side SDKs automatically track an exposure event when your code accesses a variant from a client-side Experiment SDK.
  • Server-side SDKs track an assignment event when the SDK evaluates a user, if you configure the SDK to do so. Server-side SDKs don't track exposure automatically, so you must track exposure separately if you need it.

For server-side local evaluation experiments, use the assignment event as the exposure event in your experiment analysis.

Performance

The following results reflect a single flag evaluation. Amplitude collected them over 10 executions of 10,000 evaluation iterations. Each iteration used randomized user inputs against 1 flag configuration, selected at random from 3 possible configurations.

Was this helpful?