Skip to content

PrestaShop performance testing with K6#

Author Oskar Sinkkilä
Last updated 1.2.2025

K6 Installation and testing#

Link to K6 documentation

Below is a command for installing k6. Note that this method is for Linux.

sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6

Now that the k6 is installed we can get to tests. Here is an example test called "example.js". Purpose of this test is to see how well the server can handle 100 VUs (Virtual Users). The test begins from 0 and ramps up to 100 VUs in about 20s, after which the VU count drops to 0 in 10s. Remember to change the http.get(address) to the one you want to test. You can use the vmxxxx address or your public IP.

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

export let options = {
  stages:[
    { duration: '20s', target: 100 }, // Ramp-up to 100 virtual users in 20 seconds
    { duration: '10s', target: 0 }, // Ramp-down to 0 VUs over 10 seconds
  ],
};

export default function () {
 // const res = http.get('https://fip-AAA-BBB-CCC-DDD.kaj.poutavm.fi/en/');
  const res = http.get('http://123.456.789.101');
  check(res, {
    'status is 200': (r)=> r.status === 200,
  });
  sleep(1);
}

The end result for a test looks something like this.

k6 example result

Target monitoring#

To monitor wanted target, prestashop in this case, you can use dstat.

To install dstat, use with the following command. Also remember to install dstat on the same machine as prestashop.

sudo apt install dstat
You can run dstat with the command
dstat

If you run dstat while k6 test is in progress the result looks something like the following picture.

dstat example traffic