Load testing your feathersjs server using Artillery

“Car light trails traveling along a sloped bridge.” by Casey Horner on Unsplash

Introduction

If you’re curious about the peak performance of your server or you are expecting a high load of users, load testing becomes a crucial task that you must do in order to identify bottlenecks in your application and ship a scalable server.

In this post, I will walk you through load testing a Feathers.js server using Artillery.


Artillery is a modern, powerful & easy-to-use load testing toolkit. Use it to make your applications stay scalable, performant & resilient under high load.

Getting Started

Setting up your workspace.

mkdir artillery
yarn init
yarn add artillery

Once that’s done, you’ll want to create a .yaml file. Artillery scripts are written in YAML, with the option to use javascript to write custom logic. For our case, just a .yaml file will suffice.

touch socketio-load-test.yaml

This is what my socketio-load-test.yaml file looks like:

Let’s break it down:

Target

This is where you want to point to your API. Mine is currently set to localhost:3030 where my feathersjs server is running.

Phases

A phase defines how many new virtual users will be generated in a time period. For example, in our case we have one phase called “A user fetches people” which is self explanatory.

We have also set a duration of 300s, an arrivalRate of 5 and a rampTo value of 500. This means that we want to ramp up the arrival of new users from 5 to 500 over a 5 minutes period.

Scenarios / Flow

A scenario is a sequence of steps that will be run sequentially which represents a typical sequence of requests or messages sent by a user of an application.

In scenarios, you also have flow which represents an array of operations that the virtual user will perform (this can be a GET, POST, etc).

In our case, we only have 1 flow. We want to test the performance of finding users in our feathersjs server so we query the users::find channel.

The above is really all you need to start load testing your app. My scenario is very simple, but I hope it is easy to see how this can be used to test more complex scenarios and find performance bottlenecks in your API. I am using feathersjs in my example, however this can be applied to any server, http or ws.