Core Concepts
This guide explains:
- The main concepts in Artillery
- Configuration and scenario sections in Artillery test scripts
- What load phases and virtual users are
High-level model
Artillery puts load on applications by creating virtual users. A virtual user simulates someone using an application. Load phases control when Artillery creates these users.
Virtual users
A virtual user represents a person or an API client, depending on your application.
A scenario is a sequence of actions. Each virtual user runs a scenario, such as a HTTP GET request followed by a HTTP POST request. Artillery supports HTTP, WebSocket, and Socket.io without additional plugins.
Virtual users are independent and share no state. State is the data that a user keeps between actions. For an HTTP service, each virtual user maintains its own TCP connections, cookies, and other data.
Load phases
A load phase defines user arrivals over a period of time. A load test usually has several phases. For example, a warm-up phase gradually increases the load before one or more heavy-load phases.
Load phases usually define a duration and an arrival rate. The arrival rate is the number of new virtual users per second.
This phase creates 10 new virtual users per second for 300 seconds:
phases:
- duration: 300
arrivalRate: 10Test lifecycle
Artillery starts with the first load phase in the test script. It creates new virtual users at the rate and for the duration that the phase defines.
When a phase ends, Artillery starts the next phase. It does not wait for users from the previous phase to finish. This continues until all load phases end.
Each virtual user picks one scenario from the test script and runs it to completion. The test ends when all virtual users finish their scenarios.
The test duration includes the time that all virtual users need to finish. It is at least as long as the combined load phases, but it can be much longer.
Metrics are measurements of system behavior. During a test, Artillery records and reports metrics such as response times, throughput, and errors. Throughput measures how much work a system completes over time. You can use these reports to observe performance in real time. Artillery also provides a summary when the test ends.
Test scripts
Artillery test scripts usually use YAML. You can customize them with Node.js code and any public or private npm packages. The artillery CLI runs the script. A CLI is a command-line interface.
A test script contains configuration in the config section and one or more scenarios in the scenarios section.
This example defines two load phases and one scenario:
config:
target: http://asciiart.artillery.io:8080
phases:
- duration: 60
arrivalRate: 1
- duration: 300
arrivalRate: 10
scenarios:
- flow:
- get:
url: '/dino'
- get:
url: '/armadillo'