Skip to content

CONCEPT Cited by 1 source

Session affinity

Session affinity (also called "sticky sessions") is a routing strategy that ensures all requests from a given user or session are consistently directed to the same backend instance or cluster for the duration of a defined window. In canary analysis, it provides clean experimental isolation.

Definition

Once a user is assigned to a group (baseline or canary), all subsequent requests from that user route to the same group. This prevents:

  • Cross-contamination — a user alternating between baseline and canary makes metric comparison unreliable
  • State inconsistency — if the canary cluster has different data, alternating requests see inconsistent state
  • Signal dilution — mixed routing weakens the statistical signal of behavioral-metric comparison

Netflix's "sticky canary" instance

In the Data Canary, sticky canaries use session affinity to guarantee that once a user's traffic is routed to baseline or canary clusters, it stays there for the duration of the experiment window:

"Sticky canaries use session affinity to guarantee that once a user's traffic is routed to the baseline or canary clusters, it stays there for the duration of the experiment window. This prevents cross-contamination from concurrent chaos experiments, ensuring a clean apples-to-apples comparison between data versions."

Broader applicability

Session affinity is used beyond canary analysis:

  • A/B testing — users must stay in their assigned treatment group
  • Stateful backends — session state stored in-memory requires consistent routing
  • Cache locality — routing the same user to the same node improves hit rates

Trade-offs

  • ✅ Clean experiment isolation
  • ✅ Consistent user experience during experiments
  • ❌ Uneven load distribution if user traffic is skewed
  • ❌ Reduced fault tolerance (sticky user can't be re-routed without state loss)

Seen in

Last updated · 546 distilled / 1,578 read