generated from shayancoin/aieng-template-mvp
-
Notifications
You must be signed in to change notification settings - Fork 0
Configure k6 quote CNC test for 500 RPS #534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Performance testing | ||
|
|
||
| ## Quote + CNC 500 RPS load test | ||
|
|
||
| Use the `tests/perf/k6-quote-cnc.js` scenario to generate approximately 500 requests per second (RPS) against the quote generation and CNC export APIs. | ||
|
|
||
| ### Required tooling | ||
|
|
||
| - [k6](https://k6.io/docs/getting-started/installation/) CLI v0.45.0 or later. | ||
|
|
||
| ### Environment variables | ||
|
|
||
| Set the following environment variables to target the appropriate environment and authenticate requests: | ||
|
|
||
| - `API_BASE_URL` **(recommended)** – Fully qualified base URL for the API (for example, `https://staging.api.example.com`). | ||
| - Alternatively, set `API_PROTOCOL` and `API_HOST` if you prefer to build the URL from discrete parts. Defaults to `http://localhost:8000`. | ||
| - `FRONTEND_BASE_URL` – Base URL for static frontend assets (optional, enables cache validation checks). | ||
| - You may also provide `FRONTEND_PROTOCOL` and `FRONTEND_HOST` for the same purpose. | ||
| - `API_WRITE_TOKEN` – Bearer token used to create materials, modules, and quotes. Defaults to `test-write-token` for local environments. | ||
| - `RPS` – Target request arrival rate (defaults to `500`). | ||
| - `DURATION` – How long to sustain the load (defaults to `5m`). | ||
| - `PRE_ALLOCATED_VUS` / `MAX_VUS` – k6 virtual user pool sizing for the constant arrival rate executor (defaults to `150`/`600`). | ||
|
|
||
| ### Recommended command | ||
|
|
||
| Run the following command to execute the load test locally or in CI. Adjust the base URLs and tokens to match the target environment. | ||
|
|
||
| ```bash | ||
| k6 run \ | ||
| --summary-trend-stats "avg,p(95),p(99),min,max" \ | ||
| -e API_BASE_URL="https://staging.api.example.com" \ | ||
| -e FRONTEND_BASE_URL="https://staging.fe.example.com" \ | ||
| -e API_WRITE_TOKEN="<token>" \ | ||
| -e RPS=500 \ | ||
| -e DURATION=5m \ | ||
| -e PRE_ALLOCATED_VUS=200 \ | ||
| -e MAX_VUS=600 \ | ||
| tests/perf/k6-quote-cnc.js | ||
| ``` | ||
|
|
||
| The script automatically provisions a material and module during the `setup` stage and reuses their identifiers during the load test. The scenario enforces the `p(95) < 300 ms` latency SLO and fails if more than 1% of the requests result in errors. |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fallback resource creation could overwhelm the system.
The fallback
createMaterialAndModule()on line 125 would execute for every iteration ifsetup()fails or returns invalid data. At 500 RPS over 5 minutes, this could create 150,000 materials and modules, overwhelming the database and invalidating test results.Consider removing the fallback or making setup failures explicit:
This ensures the test fails fast with a clear error message rather than attempting resource creation in the hot path.
📝 Committable suggestion
🤖 Prompt for AI Agents