feat(load_test): add optional per-user x-session-affinity#127
Open
yunyichi wants to merge 6 commits into
Open
Conversation
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.
There was a problem hiding this comment.
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.
Sent by Cursor Approval Agent: Pull Request Approver
nlsnln
approved these changes
Jul 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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 randomx-session-affinityvalue 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_startviauuid.uuid4().hexand applied after--headerprocessing, so it overrides anyx-session-affinityset 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.