Load testing, one of many valuable testing methods you can use before release to ensure that your application is bug-free and runs seamlessly. The main process of load testing is, whether an application can withstand the load of concurrent users, requests, and data volumes when in use. Artillery.io is a tool for generating load on HTTP, Socket.io and Web-Socket based applications. The artillery.io load testing tool is a Modern, Powerful & Easy to use the tool.
Key Features :
- Supports multiple protocols- HTTP(S), WEbSockets and Socket.io
- Software prefered by ecommerce backends, loT bankends and transactional APIs
- Artillery is open source under MPLv2, which is an OSI-approved, permissive, and non-viral license.
- We can see response times/latency percentiles, requests per second, concurrency, throughput, or track custom application-specific metrics with a tiny bit of Javascript code.
Installation
- Before installing artillery, Install the Latest version of Node in your device. To Install Artillery tool, Run the following command in Command Prompt
npm install -g artillery
- To check Artillery Installed or Not, run this command
artillery -V
You should see Artillery print its version if the installation has been successful.
Running Artillery Script
- Artillery allows users to run custom test scripts written in either yaml or json, users can also perform a quick test without loading external scripts. The following command specifies 20 GET requests to be sent every second for 10 seconds creating 10 virtual users per request.
artillery quick –count 10 -n 20 https://your-local-site-to-be.tested - Artillery is able to simulate realistic user behaviour with scenarios. The quick command can be useful for very simple tests only. Now let’s see how can we run a test.yaml and get the load testing results
config: target: https://your-website-link phases: - duration: 10 arrivalRate: 10 scenarios: - flow: - get: # add the url you need to send get request url: "/" capture: # capturing responce using reg expression - regexp: "[^]*" as: "response" - log: "response= {{response}}"
In this script, we specify that we are testing a service running on https://your-website-link which will be talking to over HTTP. Scenarios are actions that the users would be performing within the website e.g searching, carting items, registration etc. Scenarios are written in the configuration file which is used to run a custom test. Artillery.io also allows users to specify a file from which values can be imported to be used in a scenario. We define one load phase, which will last 10 seconds with 10 new virtual users, arriving every second (on average). We capture the response using regular expression and stores it in a variable “response”. The “response” is logged using -log at the end. We can now run the above yaml file using the following command:
artillery run test.yaml
Reading Artillery response
Artillery provides feedback for each request sent which look something like :
Started phase 0, duration: 10s @ 14:27:36(+0530) 2018-08-13 Report @ 14:27:38(+0530) 2018-08-13 Scenarios launched: 10 Scenarios completed: 10 Requests completed: 10 RPS sent: 2.13 Request latency: min: 401 max: 401 median: 401 p95: 401 p99: 401 Codes: 200: 100
A range of different statistics are displayed in the response including the number of requests, a latency report for each request, duration of each scenario ran and any HTTP status codes returned from the response. The response is printed every ten seconds by default and a final response is then printed after the test has been completed with an aggregate statistic of all the tests ran.
Request latency and scenario duration are recorded in milliseconds, p95 and p99 values represent 95th and 99th percentile values. NaN is returned if there are not enough responses received to perform the calculation.
If there are any errors (such as socket timeouts), those will be printed under Errors in the report as well.
To read about the HTTP load testing via artillery click here.
Suggestion are highly appreciated in the comments 😀
Artillery is so cool for load testing strategy!