Skip to content

feat(load_test): add optional per-user x-session-affinity#127

Open
yunyichi wants to merge 6 commits into
mainfrom
cursor/per-user-session-affinity-b8f6
Open

feat(load_test): add optional per-user x-session-affinity#127
yunyichi wants to merge 6 commits into
mainfrom
cursor/per-user-session-affinity-b8f6

Conversation

@yunyichi

@yunyichi yunyichi commented Jul 3, 2026

Copy link
Copy Markdown

Note

Low Risk
Benchmark-only client header behavior in llm_bench; no production inference or auth paths change.

Overview
Adds --per-user-session-affinity (off by default) so each Locust virtual user gets a stable random x-session-affinity value for all of its requests, which helps load tests hit multiple session-affinity / prompt-cache routes instead of collapsing onto one sticky session.

When enabled, the id is created in on_start via uuid.uuid4().hex and applied after --header processing, so it overrides any x-session-affinity set through --header. The README documents when to use this for Envoy stickiness and concurrent-user benchmarks.

Reviewed by Cursor Bugbot for commit d45ce93. Bugbot is set up for automated code reviews on this repo. Configure here.

Add --per-user-session-affinity so each Locust user gets a stable,
distinct x-session-affinity header. This spreads concurrent load across
session-affinity routes instead of collapsing serverless traffic onto a
single account-level session.
Use --session-affinity-prefix or LOAD_TEST_RUN_ID/RUN_ID/GITHUB_RUN_ID so
session ids are scoped to a workflow run ({prefix}-user-N) instead of only
the locust process pid.
Generate one random run suffix per load test and assign user-0_<id>,
user-1_<id>, ... Optional prefix/env still overrides the suffix for GHA.
Each user generates a uuid in on_start and reuses it as x-session-affinity
for the whole run. Drop run-scoped prefix machinery.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: low. Approved: optional --per-user-session-affinity is off by default, scoped to llm_bench load testing only, and matches the stated intent. Cursor Bugbot passed with no findings; Cursor Security Agent was not configured on this PR. No reviewers assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants