Learning K6, coming from Jmeter
how I can write K6 script that send 1000 request in 20 threads!?
Hi @haarTrick
Welcome to the community forum
The easiest way to achieve something similar is to run a shared-iterations executor. The number of thread would be the number of virtual users (VUs) and you can have those users share 1000 iterations. That is, if each iteration in your case has a single request like in the example below.
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
discardResponseBodies: true,
scenarios: {
contacts: {
executor: 'shared-iterations',
vus: 20,
iterations: 1000,
maxDuration: '5m',
},
},
};
export default function () {
http.get('https://test.k6.io/contacts.php');
sleep(0.5);
}
If you are new to k6 I would recommend, apart from the documentation, to have a look at GitHub - grafana/k6-learn, particularly k6-learn/08-Setting-load-profiles-with-executors.md at main · grafana/k6-learn · GitHub. And also have a read at Understanding the Different Types of Load Tests: Goals and Recommendations, Intro to API Load Testing: The k6 Guide (if you are testing APIs) and Running large tests.
I hope this helps
Cheers!
Hi eyewebe
I appreciate your help
I don’t think this what I looking for.
I want to send 1000 requests in 20 threads (groups) in a 20s from different load zones.
I have been though the documents last two days. K6 seems to me use a different approach
Hi @haarTrick
My understanding of JMeter is limited. I was under the impression that threads would be equivalent to VUs and the requests would be the iterations.
If you are looking for different load zones, you might have to look into:
- k6 cloud: Load zones
- Running distributed load: Running distributed k6 tests on Kubernetes
k6 runs in a single instance, unless you need to scale up (or distribute in load zones).
I hope this helps.
Cheers!