Skip to content

Latest commit

 

History

History
 
 

loadtest

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Performance Benchmarking Setup

The setup uses docker compose to get the required components up and running. It also handles running database migration and starts K6 load testing script at the end. The metrics are visible in the console as well as through Grafana dashboard.

We have added a callback at the end of the script to compare result with existing baseline values. The env variable LOADTEST_RUN_NAME can be used to change the name of the run which will be used to create json, result summary and diff benchmark files. The default value is "baseline", and diff will be created by comparing new results against baseline. See 'How to run' section.

Structure/Files

config: contains router toml file to change settings. Also setting files for other components like Tempo etc.

grafana: data source and dashboard files

k6: K6 load testing tool scripts. The setup.js contain common functions like creating merchant api key etc. Each js files will contain load testing scenario of each APIs. Currently, we have health.js and payment-confirm.js.

.env: It provide default value to docker compose file. Developer can specify which js script they want to run using env variable called LOADTEST_K6_SCRIPT. The default script is health.js. See 'How to run' section.

How to run

Build image of checked out branch.

docker compose build

Run default (health.js) script. It will generate baseline result.

bash loadtest.sh

The loadtest.sh script takes following flags,

-c: compare with baseline results [without argument] auto assign run name based on current commit number

-r: takes run name as argument (default: baseline)

-s: script name exists in k6 directory without the file extension as argument (default: health)

-a: run loadtest for all scripts existing in k6 directory [without argument]

For example, to run the baseline for payment-confirm.js script.

bash loadtest.sh -s payment-confirm

The run name could be anything. It will be used to prefix benchmarking files, stored at ./k6/benchmark. For example,

bash loadtest.sh -r made_calls_asyns -s payment-confirm

A preferred way to compare new changes with the baseline is using the -c flag. It automatically assigns commit numbers to easily match different results.

bash loadtest.sh -c -s payment-confirm

Assuming there is baseline files for all the script, following command will compare them with new changes,

bash loadtest.sh -ca

It uses -c compare flag and -a run loadtest using all the scripts.

Developer can observe live metrics using K6 Load Testing Dashboard in Grafana. The Tempo datasource is available to inspect tracing of individual requests.

Notes

  1. The script will first "down" the already running docker compose to run loadtest on freshly created database.
  2. Make sure that the Rust compiler is happy with your changes before you start running a performance test. This will save a lot of your time.
  3. If the project image is available locally then docker compose up won't take your new changes into account. Either first do docker compose build or docker compose up --build k6.
  4. For baseline, make sure you in the right branch and have build the image before running the loadtest script.