1. Install k6 on Windows
You have a few options. Iโll show the two easiest:
Option A โ Using winget (recommended if available)
- Open Windows Terminal / PowerShell as Administrator.
- Run:
winget install grafana.k6 - After install, verify:
k6 versionYou should see something like:k6 v0.xx.x
Option B โ Using Chocolatey
If youโre already using Chocolatey:
- Open PowerShell (Admin).
- Install:
choco install k6 - Verify:
k6 version
Option C โ Portable (ZIP) Binary (no package manager)
- Go to:
https://github.com/grafana/k6/releases(in your browser). - Download the latest Windows x64 .zip.
- Extract it to a folder, e.g.:
C:\tools\k6\ - Add that folder to your PATH:
- Press
Winโ search Environment Variables โ โEdit the system environment variablesโ. - Click Environment Variablesโฆ
- Under User variables or System variables, select
Pathโ Edit โ New โ add:C:\tools\k6\ - Click OK several times.
- Press
- Open a new PowerShell and run:
k6 version
2. Create a Project Folder
Letโs keep things clean.
- Choose a workspace folder, e.g.:
mkdir C:\k6-demo cd C:\k6-demo - Youโll put all your k6 scripts here.
3. Your First โHello Worldโ k6 Script
Weโll create a very simple script that:
- Sends 1 HTTP GET request to a test URL.
- Checks that the response status is 200.
- Prints basic stats at the end.
3.1 Create the script file
- In
C:\k6-demo, create a file namedhello-world.js.
If you like using Notepad:
notepad .\hello-world.js
Code language: CSS (css)
Paste this code inside:
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 1, // number of virtual users
duration: '10s', // total test duration
};
export default function () {
// 1) Make a simple GET request
const res = http.get('https://test.k6.io');
// 2) Validate response
check(res, {
'status is 200': (r) => r.status === 200,
});
// 3) Small pause between iterations
sleep(1);
}
Code language: JavaScript (javascript)
Save and close the file.
4. Run the Hello World Test
From inside the folder:
cd C:\k6-demo
k6 run .\hello-world.js
Code language: CSS (css)
You will see something like:
/\ |โพโพ| /โพโพ/ /โพโพ/
/\ / \ | |/ / / /
/ \/ \ | ( / /
/ \ | |\ \/ /
/ __________ \ |__| \____/
execution: local
script: hello-world.js
output: -
scenarios: (100.00%) 1 scenario, 1 max VUs, 10s max duration (incl. graceful stop):
* default: 1 looping VUs for 10s (gracefulStop: 30s)
running (10.0s), 0/1 VUs, 10 complete and 0 interrupted iterations
default โ [======================================] 1 VUs 10s
โ status is 200
checks...................: 100.00% โ 10 โ 0
http_req_duration........: avg=150ms min=120ms max=200ms ...
http_reqs................: 10 (1.0/s)
vus......................: 1
Code language: PHP (php)
5. Understand the Output
Important fields to understand:
- checks โ shows how many checks passed/failed:
โ 10 โ 0โ all 10 requests returned status 200.
- http_req_duration โ time it took to complete each HTTP request.
avg,min,max, percentiles.
- http_reqs โ total number of HTTP requests (10 here).
- vus โ how many virtual users were active (1 here).
Since status is 200 is the only check, if the website failed or returned a different code, youโd see failed checks.
6. Slightly More Interesting Example (Hello World with Threshold)
Now, letโs add a threshold so the test โfailsโ if latency is too high.
Create another file: hello-with-threshold.js
notepad .\hello-with-threshold.js
Code language: JavaScript (javascript)
Paste:
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 2,
duration: '15s',
thresholds: {
// 95% of all requests must finish below 500ms
http_req_duration: ['p(95) < 500'],
// At least 99% of checks must pass
checks: ['rate > 0.99'],
},
};
export default function () {
const res = http.get('https://test.k6.io');
check(res, {
'status is 200': (r) => r.status === 200,
});
sleep(1);
}
Code language: JavaScript (javascript)
Run it:
k6 run .\hello-with-threshold.js
Code language: JavaScript (javascript)
At the end, youโll see something like:
checks................: 100.00% โ 30 โ 0
http_req_duration.....: p(95)=180ms ...
thresholds:
* http_req_duration p(95)<500 โ passed
* checks rate>0.99 โ passed
Code language: HTML, XML (xml)
If you intentionally use a slow or broken URL, you might see thresholds marked as failed with โ.
7. Running a Quick โSmoke Testโ Style Hello World
If you just want to quickly confirm your script works (like a smoke test):
Create hello-smoke.js:
notepad .\hello-smoke.js
Code language: CSS (css)
Paste:
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
vus: 1,
iterations: 1, // run only once
};
export default function () {
const res = http.get('https://test.k6.io');
console.log(`Response status: ${res.status}`);
sleep(1);
}
Code language: JavaScript (javascript)
Run:
k6 run .\hello-smoke.js
Code language: CSS (css)
Youโll see a log line:
INFO[0000] Response status: 200
Code language: CSS (css)
This is a super basic โHello Worldโ just to embed k6 in a CI step or script.
8. Typical Folder Structure for Your k6 Work
If you continue learning, you might organize like:
C:\k6-demo
โโ hello-world.js
โโ hello-with-threshold.js
โโ hello-smoke.js
โโ scenarios/
โ โโ basic-load.js
โ โโ spike-test.js
โโ data/
โ โโ users.csv
Code language: JavaScript (javascript)
9. Next Easy Steps After Hello World
Once this works, good next things to explore:
- Increase load
Change:vus: 10, duration: '30s', - Add multiple URLs
Usegroup()blocks and multiplehttp.getcalls. - Export results to JSON (for later analysis):
k6 run --out json=results.json .\hello-world.js - Integrate with Grafana later (Prometheus or k6 Cloud), once youโre comfortable.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals
This demo lab is an excellent introduction to integrating load-testing right into the development lifecycle with Grafana k6. It shows how developers and QA teams can simulate realistic traffic using JavaScript-based scripts to uncover performance bottlenecks before deployment โ a critical practice for building scalable, resilient applications. By highlighting how to configure virtual users, ramp up/down load, and visualize results (especially when paired with observability tools), the article makes it clear that performance testing doesnโt have to be an afterthought. Overall, a very practical guide for teams wanting to embed performance and reliability checks early in their CI/CD pipelines โ thanks for sharing!