Use load testing to ensure that your Blnk deployment can handle expected traffic and maintain performance under various conditions. This is a critical step in setting up your Blnk server.

Blnk uses k6, a modern load testing tool to manage this process. This guide will walk you through setting up and running a load test on your Blnk server using k6 with insights from a sample test result to help you understand and interpret your data.

Before you start

Make sure you have:

  1. Cloned the Blnk repository to your local machine;
  2. Docker and Docker Compose installed, for running the Blnk server;
  3. k6 installed on your machine. Visit k6.io for installation instructions.

Set up your load test

1

Clone the Blnk repository

If the Blnk repository isn’t already cloned:

git clone https://github.com/blnkfinance/blnk && cd blnk

Deploy your Blnk server if you haven’t done so yet:

Deploy Blnk

Start here to run your Blnk server

2

Navigate to the load test directory

Switch to the load test folder within the Blnk repository.

bash
cd tests/loadtest
3

Review the load test script

The script.js file in the load test directory outlines the test:

  • It sends HTTP POST requests to the /transactions endpoint of the Blnk server.
  • Each request simulates a transaction with a unique reference ID, generated using the uuidv4 function.
  • The script is set to run with 5 virtual users (VUs) for 30 seconds.
4

Load test script (script.js)

script.js
import http from "k6/http";
import { uuidv4 } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js';
import { check, sleep } from "k6";

export const options = {
    vus: 5,
    duration: '30s',
};

export default function () {
    const url = 'http://localhost:5001/transactions';
    const payload = JSON.stringify({
        "amount": 100,
        "allow_over_draft": true,
        "reference": uuidv4(),
        "currency": "USD",
        "source": "@cash",
        "destination": "@interests"
    });

    const params = {
        headers: {
            'Content-Type': 'application/json',
        },
    };

    let response = http.post(url, payload, params);
    check(response, {
        'is status 201': r => r.status === 201,
    });
}
5

Run the load test

Within the tests/load directory:

bash
k6 run script.js

Need help?

We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool.

To ask questions or discuss issues, please join our Discord community.

Get access to Blnk Cloud.

Manage your Blnk Ledger and explore advanced features (access control & collaboration, anomaly detection, secure storage & file management, etc.) in one dashboard.