{"title":"Review k6 Thresholds Before Running Generated Load","excerpt":"A generated k6 script is a bounded first probe. Its fixed 200 check and default 500 ms limits need review against the endpoint contract.","canonicalUrl":"https://automationtester.in/blog/tools-reviews/review-k6-script-thresholds-before-load","category":{"name":"Tools & Reviews","slug":"tools-reviews"},"tags":["k6","load-testing","performance","thresholds"],"author":{"name":"Shashank Rawlani","url":"https://shashank.rawlani.com","linkedin":"https://www.linkedin.com/in/shashankrawlani/"},"datePublished":"2026-11-18T05:30:00.000Z","dateModified":"2026-11-18T05:30:00.000Z","coverImage":{"url":"https://ik.imagekit.io/automationtester/automationtester-in/blog/covers/v3/review-k6-script-thresholds-before-load.webp","alt":"Four green virtual-user markers feed request-duration bars. One longer orange bar branches toward a crossed-out marker, while the green set reaches a dashed threshold gate."},"contentHtml":"<p>The <a href=\"https://automationtester.in/tools/k6-generator\">k6 Script Generator</a> can give you a bounded first load probe: one request, a virtual-user count, a duration, and pass/fail thresholds. Before the run, inspect the generated checks. Their defaults may disagree with your endpoint’s contract.</p>\n\n<p>A team asks whether an orders endpoint can handle a promotion. A form asking for “number of users” looks tempting, but five concurrent users for twenty seconds do not model a promotional arrival rate. The generator can build the first probe; sizing the real load still needs traffic evidence.</p>\n\n<h2 id=\"k6-build-small\">Build a five-user probe</h2>\n<p>On the live page, set the endpoint to <code>https://api.example.test/orders</code>, leave the method at GET, set <strong>Virtual Users</strong> to <code>5</code>, and set <strong>Duration</strong> to <code>20s</code>. The generated options began exactly this way:</p>\n<pre class=\"language-javascript\"><code class=\"language-javascript\">export const options = {\n  vus: 5,\n  duration: '20s',\n  thresholds: {\n    http_req_duration: ['p(95)&lt;500'],\n    http_req_failed: ['rate&lt;0.01'],\n  },\n};</code></pre>\n<p>The script also sends <code>http.get()</code> with the default placeholder bearer header, checks for status 200 and a transaction time below 500 ms, then sleeps one second. Replace the placeholder token and test host with controlled values. Do not run the example URL: <code>example.test</code> is an illustrative host.</p>\n\n<h2 id=\"k6-threshold-check\">Two different latency decisions</h2>\n<p>The <code>http_req_duration</code> threshold decides whether the entire run passes when its p95 is under 500 ms. The generated <code>check</code> compares each response’s <code>timings.duration</code> against 500 ms. Those are different questions. A handful of slow requests may fail checks while the run’s p95 still passes. Decide whether you need both signals, and set each from the service objective rather than from the form’s default.</p>\n\n<p>The status check is hard-coded to 200. An endpoint whose successful POST returns 201 will mark every request as a failed check until you edit that line. The UI can flag an empty endpoint or invalid JSON body, but it cannot know your API’s status contract.</p>\n\n<h2 id=\"k6-load-model\">When five users are the wrong input</h2>\n<p>Constant virtual users are useful for a first controlled probe. If the business question is “200 arrivals per second at peak,” choose a k6 arrival-rate scenario and derive the rate, journey mix, and test-data ownership from measurements. Running a load test against shared production dependencies without a coordinated plan can disturb other users.</p>\n\n<h2 id=\"k6-next\">Run a bounded first pass</h2>\n<p>Generate a script for a test environment, edit the expected status and thresholds, then run <code>k6 run load-test.js</code>. Save the script, target environment, and summary together. The result is useful only when the load profile and endpoint behavior are stated.</p>\n\n<h2 id=\"k6-docs\">References for the run</h2>\n<ul><li><a href=\"https://automationtester.in/tools/k6-generator\">k6 Script Generator</a>: live generated script and form controls.</li><li><a href=\"https://grafana.com/docs/k6/latest/using-k6/thresholds/\">k6 thresholds</a>: pass/fail expressions for metrics.</li><li><a href=\"https://grafana.com/docs/k6/latest/using-k6/scenarios/executors/constant-vus/\">k6 constant VUs</a>: the executor behavior behind the generated load profile.</li></ul>"}