Easy Load Test with k6

When building a website or API, it's not just about making things look good or function correctly — performance matters too. How would the app behave under pressure? Is it going to crash when it gets too many requests? That’s where load testing comes in.

In this blog, I’ll show you how to get started with one of the easiest tools out there: k6. Whether you're a developer, QA engineer, or just curious, this guide will help you run your first load test in less than 10 minutes.

What is k6?

k6 is an open-source load testing tool built for developers. It’s written in Go, but you write test scripts in JavaScript — making it approachable. You can test REST APIs, GraphQL, and even your website performance with it.

Step 1: Install k6

Let's start by installing it. First, open the terminal. For this blog, I'll only show macOS because Windows is tiresome for me and I don't have Linux anymore

For macOS (using Homebrew)

brew install k6

Then you can verify it with

k6 version

If it responds something like this

k6 v0.54.0

then you're good

Step 2: Create Your First Test

Step 2: Create Your First Test

Now let's create a simple test script. This one hits an API endpoint and checks if it returns a status code of 200 (success).

Create a file called test.js. You can create it by using terminal. Like this

touch test.js .

then in the file. Add this:

import http from 'k6/http';
import { check } from 'k6';

export default function () {
  const res = http.get('https://test-api.k6.io/');
  check(res, { 'status is 200': (r) => r.status === 200 });
}

This script will:

  • Send a GET request to https://test-api.k6.io/
  • Check that the status code is 200

Step 3: Run the Test

Run it with this command:

k6 run test.js

And you’ll see an output like this:

running (10.0s), 0/1 VUs, 10 complete and 0 interrupted
default ✓ [======================================] 1 VUs  10s

    ✓ status is 200

    checks.........................: 100.00% ✓ 100
    http_req_duration..............: avg=120ms min=110ms max=135ms

It's pretty easy, eh? By default, it runs with 1 virtual user (VU) for 10 seconds. You can customize the VU and duration as well, but for now, it should be good enough to get started.

Final Thoughts

k6 makes load testing feel very easy. It's simple, lightweight, easy to create a script and developer-friendly.

I'll be sure to write up more complex solutions for different real world using. To be honest, you'll thank yourself later if you regularly do load testing on your system because when it's crashed, your reputation won't hatch back that easily.

However, if the scenario is too complex, you can contact us here for help

And here's why we should use k6 if you're curious

Let's Bring

Your Ideas to Life

Whether you’re starting fresh or refining your vision, we’re here to bring it to life. Let’s collaborate and build your perfect solution together!