import http from 'k6/http'; import { check } from 'k6'; export const options = { scenarios: { // Ramp up from 10 to 50 virtual users pushing sustained load sustained_load: { executor: 'ramping-vus', startVUs: 10, stages: [ { duration: '10s', target: 50 }, // Ramp up to 50 VUs { duration: '30s', target: 50 }, // Stay at 50 VUs (~1,000+ req/s) { duration: '5s', target: 0 }, // Ramp down ], }, }, thresholds: { http_req_duration: ['p(95)<50'], // 95% of API responses under 50ms http_req_failed: ['rate<0.01'], // Less than 1% failure }, }; export default function () { const url = __ENV.API_URL || 'http://localhost:8000/api/v1/cdr/raw'; const payload = JSON.stringify({ raw_id: `load-${__VU}-${__ITER}-${Date.now()}`, src_ip: '10.240.1.1', device_id: '310410998877665', caller_num: '+19875551234', svc: '4G_DATA', up_bytes: 1048576, down_bytes: 4194304, rat: 6, lac: '4021', ci: '8812', epoch_start: 1726070000, epoch_end: 1726070300, }); const params = { headers: { 'Content-Type': 'application/json' }, }; const res = http.post(url, payload, params); check(res, { 'status is 202 or 429': (r) => r.status === 202 || r.status === 429, }); }