Performance - API

If an end user perceives bad performance from your website, her next click will likely be on your-competition.com.

This document is a short intro on performance testing and using k6 and JMeter, two performance testing tools.

Performance testing 101

In a nutshell, performance testing is checking the stability & responsiveness of a system under a certain workload. Every system has its limits, performance testing is used to find those limits.

Performance and user experience are tightly correlated. The two big factors you wish to analyze are stability (does the system work under load?) and responsiveness (is the system quick enough under load).

Rule of thumb for responsiveness

These highly depend on the context, but in general:

See this interesting article on UX and time scales.

Modalities

Other important metrics

Approach

Since performance testing can be done in a variety of ways, it is crucial to:

When to test

Again, this depends on the context of the project, but here are some potential triggers:

Where to test

Most of the time:

Use the expertise of our DevOps team to get a test environment up and running.

What to test

How to test

There is no silver bullet. Experimentation and project context will get you on the right path.

Some important parameters that you will need to decide upon are:

k6.io

Installing k6

Usage

You can do one of three things:

Sample test

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

export let options = {
    vus: 50,
    duration: '60s'
};

export default function() {
    let url = `https://myurl`;
    let response = http.get(url);

    check(response, {
        'Status was 200': r => r.status == 200,
        'Transaction time was below 1000ms': r => r.timings.duration < 1000
    });
}

Converting your HAR file to a k6 script

Postman-to-k6

Running a load test with your k6 script

Useful docs

JMeter

JMeter is Apache's load testing tool that is sometimes perceived as the industry standard.

Installation & running

Components

JMeter works with components. This is a very broad overview:

Find more info on the above in Apache's Introduction docs.

Building a simple test plan

jmeter-example.png

Running a simple test plan


load-testing.gif