Skip to main content

Performance Tests

Description

Performance tests are designed for teams to ensure that API usage within the project remains performant & resilient under high load. This is achieved by running a load test script that simulates high-traffic loads on the application. This ensures that the application can handle the load and that it does not become unresponsive or slow to respond to requests from the user.

Artillery

Load testing is a common strategy used to identify potential performance bottlenecks in applications between changes to proactively identify potential areas where the user experience can be affected, i.e. increased response times for API requests contributing to increased load times. This is one of many examples where the decreased level of performance quality can directly impact user experience. The process of initiating a load test script could be achieved with a tool called Artillery.

Artillery is an open-source, load-testing toolkit for developers and DevOps engineers. It is designed to test the scalability and performance of your application by simulating high-traffic loads.

Utilising this could involve observing thousands of requests per hour during peak periods providing the opportunity to conduct tests at various volumes for the user journey. To achieve this, separate scripts can be made, in a language that accommodates the rest of the project and automates the entire (or selected parts) of the application's user journey, verifying functionality through various checkpoints. Playwright is a common accommodating tool that can used within the scripts to achieve this.

These scripts can then be referenced inside a yaml file which artillery uses to run the script with the automated tooling with multiple configurations available for customisations:

config:
plugins:
expect:
outputFormat: pretty
target: 'http://localhost:3000/N23NBBW01/registration'
phases:
- duration: 120
arrivalRate: 1
engines:
playwright:
defaultTimeout: 120000
processor: ./scripts/eventRegJourney_rebuild.js
scenarios:
- name: 'Run Event reg performance test for rebuild'
engine: playwright
flowFunction: 'eventRegistrationJourney'

The command for running the artillery scripts can be defined in a package.json file which can then be referenced from any other location within the project:

  "scripts": {
"registration:rebuild": "artillery run eventReg_rebuild_perfTest.yml --output ./reports/registration_rebuild.json",
"registration:rebuild:generateReport": "artillery report --output ./reports/registration_rebuild.html ./reports/registration_rebuild.json"
...
}

Running artillery tests should preferably be done in a dedicated performance environment which can be created upon the workflow run's initiation and then be deleted after the tests have been completed (i.e. Online Payments) during the CI/CD stage of the development process or locally (such as through manual command run or optional as part of an option to a suitable Git hook where it can then optionally run). The reason for this is due to minimizing hosting costs where suitable to avoid exceeding available usage within given hosting plans. There also needs to be care taken in regards to which other services (outside the project's scope) would be affected by the loading tests.

Examples

References & Further Reading