Guide to Load Testing with Artillery

Karthik S
3 min readFeb 15, 2024

--

Artillery.io is an open-source load testing toolkit that enables developers to simulate thousands of virtual users interacting with their systems. It offers an intuitive YAML-based DSL or JavaScript scripting for defining test scenarios, with features like real-time and post-test reporting for in-depth performance analysis. Ideal for CI/CD pipelines, Artillery.io ensures the reliability and scalability of applications before deployment.

Introduction

In this comprehensive guide, we’ll explore how to perform load testing using Artillery. Load testing is crucial for ensuring the stability and performance of your web applications under various traffic conditions.

In this guide, I will perform the following scenarios on the following system specifications

  • Operating System: Ubuntu 20.04
  • RAM: 4GB
  • Storage: 30GB
  • Architecture: 64-bit

Prerequisites

Before installing and using Artillery, ensure that you have Node.js installed. Artillery requires the most recent LTS release of Node.js. You can install Node.js by following the instructions on the official Node.js website.

Installing Artillery CLI

Follow these steps to install Artillery globally via npm:

  1. Open your Terminal or command prompt.
  2. Run the following command to install Artillery globally
npm install -g artillery@latest

If you encounter permission denied issues during installation, use the following command with administrative privileges

sudo npm install -g artillery@latest

Once installed, you can verify the installation by running

artillery version

Create an Artillery test script

Now, let’s create a test script to define the load testing scenarios. Create a directory for your load testing

mkdir artillery
cd artillery

Now, let’s create a test script using the nano text editor. You can use any text editor of your choice.

nano load-test.yml

Paste the following contents into the script

config:
target: http://asciiart.artillery.io:8080
phases:
- duration: 60
arrivalRate: 1
rampTo: 5
name: Warm up phase
- duration: 60
arrivalRate: 5
rampTo: 10
name: Ramp up load
- duration: 30
arrivalRate: 10
rampTo: 30
name: Spike phase

scenarios:
- name: Get 3 animal pictures
flow:
- loop:
- get:
url: "/dino"
- get:
url: "/pony"
- get:
url: "/armadillo"
count: 100

Save the file (Ctrl + O & Press Enter) and exit the editor (Ctrl + X).

Test script walk through

The test script consists of two main sections: config and scenarios. Here's a brief explanation:

  • config is what defines how our load test will run, e.g. the URL of the system we're testing, how much load will be generated, any plugins we want to use, and so on.
  • scenarios is where we define what the virtual users created by Artillery will do. A scenario is usually a sequence of steps that describes a user session in the app.

Run the Test Script

To run the test script, execute the following command

artillery run load-test.yml

Artillery will execute the test script, launching virtual users as per the specified configuration. It will provide periodic reports detailing metrics such as response times, request rates, etc.

Conclusion

Congratulations! You’ve successfully executed your first load test using Artillery. Load testing is a critical aspect of ensuring the performance and reliability of your applications, and Artillery provides a powerful toolkit to streamline this process. Experiment with different scenarios and configurations to gain insights into your application’s behavior under various load conditions.

Reference https://www.artillery.io/docs/get-started/

--

--

Karthik S
Karthik S

Written by Karthik S

DevOps Engineer at Icanio Technologies, sharing insights on automation and cloud technologies. Helping others navigate the DevOps journey.

Responses (2)