Get Started
Learn Core Concepts

Core Concepts

You’ll learn:

  • Key high-level concepts for using Artillery
  • Configuration and scenario sections in Artillery test scripts
  • What load phases and virtual users are

High-level model

Artillery puts load on apps by launching virtual users which arrive to use the app in phases. Those are two core concepts in Artillery. A load test is just load phases + virtual users.

Virtual users

A virtual user emulates a real user interacting with your app. A "real user" may be a person, or an API client depending on your app.

A virtual user executes a scenario, which is usually a sequence of actions, such as making a HTTP GET request, followed by a HTTP POST request and so on. Artillery supports a variety of diferent types of systems out of the box, such as HTTP, WebSocket, and Socket.io.

All virtual users are completely independent of each other, just like users in the real world, and share no state. For example, when testing an HTTP-based service, each virtual user will open & maintain its own TCP connections, and maintain its own cookies and any other data.

Load phases

A load phase tells Artillery how many virtual users to create over a period of time. A production-grade load test will usually have multiple load phases, such as:

  • A warm up phase, which will gently increase load over a period of time
  • One or more heavy load phases

Load phases are expressed as duration + an arrival rate. Each arrival is a new virtual user.

For example, the following is an example of a load phase spec:

phases:
  - duration: 300
    arrivalRate: 10

This is a load phase that last 300 seconds, with 10 new virtual users being launched every second.

Test lifecycle

To run a load test, Artillery starts with the first load phase defined in the test script.

It will launch a number of new virtual users every second, for the duration specified by the load phase.

Artillery will then move on to the next load phase launching more virtual users, and do this until there are no more load phases left. Artillery does not wait for virtual users created by one phase to finish before starting the next phase.

Each virtual user will pick and run one of the scenarios in the test definition and run it to completion. A test run ends when all virtual users finish running their scenarios.

The duration of a load test is the amount of time it takes for all virtual users created by the load phases to finish their scenarios. This is always at least as long as the combined duration of load phases, but can be much longer.

As Artillery runs a test, it will track and record performance metrics, such as API response times, throughput, and errors. As the test runs, Artillery will report those metrics so that performance of the system can be observed in real-time. A summary report is also provided at the end of the test run.

Test scripts

Artillery test definitions are usually written as YAML (with the option for near-infinite customization with Node.js code, which may use any public or private npm packages). The artillery CLI is then used to run that test definition.

A test definition is composed of one or more scenarios (in the scenarios section) and test config (in the config section).

A "hello world" Artillery test definition looks like this:

config:
  target: http://asciiart.artillery.io:8080
  phases:
    - duration: 60
      arrivalRate: 1
    - duration: 300
      arrivalRate: 10
scenarios:
  - flow:
      - get:
          url: '/dino'
      - get:
          url: '/armadillo'