Use Case:
My backend only allows one signup request per unique email ID. If the same email is used again, it returns a 401 Unauthorized
error.
My company asked me to conduct load testing with 100 Virtual Users (VUs), but did not provide further instructions.
π What I Want
- Each VU should send only one signup request using a unique email.
- Emails must not repeat across VUs.
- Test should simulate realistic load with 100 VUs.
π§ My Current k6 Script
import http from 'k6/http'; import config from '../../config/configuration.js'; import { check } from 'k6';
export const options = {
stages: [
{ duration: β10sβ, target: 20 },
{ duration: β10sβ, target: 50 },
{ duration: β10sβ, target: 100 },
{ duration: β20sβ, target: 100 },
{ duration: β10sβ, target: 0 },
],
thresholds: {
http_req_duration: [βp(95)<400β],
http_req_failed: [βrate<0.10β],
},
};let users;
try {
users = JSON.parse(open(β../../data/demo.jsonβ));
} catch (error) {
console.error(βError reading user data:β, error);
}export default function () {
if (__ITER === 0) {
const selectedUser = users[__VU - 1];
const signupUrl =${config.urls.AUTH_BASE_URL}/user/signup/email
;const signupPayload = JSON.stringify({ email: selectedUser.email, password: selectedUser.password, deviceInfo: { model: "Pixel 4", platForm: "Android", osVersion: "13", operatingSystem: "android" } }); const headers = { ...config.headers }; const signupRes = http.post(signupUrl, signupPayload, { headers }); check(signupRes, { 'Signup returned 200': (r) => r.status === 200, });
}
}
β My Questions
- Is this the correct approach to simulate load when only one request per account is allowed?
- Should I use per-VU iteration or shared-iterations in this case?
- How do I monitor separate APIs using tags in Grafana without mixing metrics?
π― Goal
Run a realistic load test using 100 unique user signups, with clear monitoring of API performance per endpoint.