// This file aims to test a case where 80 users send 3 messages. // This test aims to help us identify the most appropriate huggingface hardware. import http from 'k6/http'; import { sleep, check } from 'k6'; export const options = { scenarios: { my_spike_test: { executor: 'per-vu-iterations', vus: 80, // 80 total users iterations: 1, // Each user runs the script exactly once }, }, }; export default function () { // Each VU must wait a random time period to prevent them from // sending their messages at the exact same time. sleep(Math.random() * 10); // const url = 'https://marvin-cusm-chatbot-champ-chatbot.hf.space/ping' const url = 'http://localhost:8000/ping' // Each VU sends 3 messages for (let i = 0; i < 3; i++) { const res = http.get(url); check(res, {'status is 200': (r) => r.status === 200}) // Users usually wait before sending another message. // It takes time to read the response and write another message. // Simulate reading speed: ~200ms per word in the reply + 2s thinking time // The average reply contains 48 words. const readingTime = (71 * 0.2) + 2; // Cap it so it doesn't wait forever, but add some randomness (jitter) const finalSleep = Math.min(readingTime, 15) + (Math.random() * 3); sleep(finalSleep); } } // CHAMP // HTTP // http_req_duration..............: avg=1.26s min=82.17ms med=966.3ms max=3.74s p(90)=2.35s p(95)=2.88s // { expected_response:true }...: avg=1.26s min=82.17ms med=966.3ms max=3.74s p(90)=2.35s p(95)=2.88s // http_req_failed................: 0.00% 0 out of 60 // http_reqs......................: 60 0.983133/s