Stress testing with Artillery

To ensure a server can handle a certain amount of requests per second for a certain delay, we can use stress testing.

Artillery is a library for stress testing. We define scenarios in a YAML file and how we want to simulate users making requests accord to scenarios. Here is an example of configuration for a chat application:

# chat.yaml
target: "http://localhost:3333"
# Create up to 10 virtual users per second in one minute
- duration: 60
arrivalRate: 10
# Create up to 100 virtual users per second in ten minutes
- duration: 600
arrivalRate: 100
# Enable sending events
- engine: "socketio"
# Create a user
- post:
url: "/sign-up"
username: "Jean-Louis Murat"
password: "La Princesse of the Cool"
# Get my information
- get:
url: "/me"
# Add a friend
- post:
url: "/friend"
id: "b0518bea-4df4-415c-a01d-129ecae34c33"
# Send a message to my friend
# HTTP requests and events can be mixed!
- emit:
channel: "chat"
userId: "b0518bea-4df4-415c-a01d-129ecae34c33"
message: "Hello JL!"

Join my mailing list

Get monthly insights, personal stories, and in-depth information about what I find helpful in web development as a freelancer.

Email advice once a month + Free XState report + Free course on XState

I value your privacy and will never share your email address.