UNPKG

108 kBMarkdownView Raw
1# Serverless-artillery [![Build Status](https://travis-ci.org/Nordstrom/serverless-artillery.svg?branch=master)](https://travis-ci.org/Nordstrom/serverless-artillery) [![Coverage Status](https://coveralls.io/repos/github/Nordstrom/serverless-artillery/badge.svg?branch=master)](https://coveralls.io/github/Nordstrom/serverless-artillery?branch=master)
2
3[//]: # (Thanks to https://www.divio.com/en/blog/documentation/)
4
5# Introduction
6Combine [`serverless`](https://serverless.com) with [`artillery`](https://artillery.io) and you get `serverless-artillery` (a.k.a. `slsart`).
7
8Serverless-artillery makes it easy to test your services for performance and functionality quickly, easily and without having to maintain any servers or testing infrastructure.
9
10### Use serverless-artillery if
111. You want to know if your services (either internal or public) can handle different amount of traffic load (i.e. performance or load testing).
121. You want to test if your services behave as you expect after you deploy new changes (i.e. acceptance testing).
131. You want to constantly monitor your services over time to make sure the latency of your services is under control (i.e. monitoring mode).
14
15# Table of Contents
16- [Installation](#installation)
17 - [Installing on local machine](#installing-on-local-machine)
18 - [Prerequisite](#prerequisite)
19 - [1. Node JS](#1-node-js)
20 - [2. Serverless Framework CLI](#2-serverless-framework-cli)
21 - [Installing serverless-artillery](#installing-serverless-artillery)
22 - [Installing in Docker](#installing-in-docker)
23- [Uninstallation](#uninstallation)
24- [How it works?](#how-it-works)
25 - [Load generator Lambda function on AWS](#load-generator-lambda-function-on-aws)
26- [Before running serverless-artillery](#before-running-serverless-artillery)
27 - [Setup for Nordstrom Technology](#setup-for-nordstrom-technology)
28 - [Setup for everyone else](#setup-for-everyone-else)
29- [Tutorial 1: Run a quick performance test](#tutorial-1-run-a-quick-performance-test)
30 - [1. Setup AWS account credentials](#1-setup-aws-account-credentials)
31 - [2. Command line](#2-command-line)
32 - [3. Deploy](#3-deploy)
33 - [4. Invoke](#4-invoke)
34 - [5. Remove](#5-remove)
35- [Tutorial 2: Performance test with custom script](#tutorial-2-performance-test-with-custom-script)
36 - [1. Create new directory](#1-create-new-directory)
37 - [2. Create `script.yml`](#2-create-scriptyml)
38 - [3. Understanding `script.yml`](#3-understanding-scriptyml)
39 - [4. Customizing `script.yml`](#4-customizing-scriptyml)
40 - [5. Setup AWS account credentials](#5-setup-aws-account-credentials)
41 - [6. Deploy assets to AWS](#6-deploy-assets-to-aws)
42 - [7. Invoke performance test](#7-invoke-performance-test)
43 - [8. Remove assets from AWS](#8-remove-assets-from-aws)
44- [Tutorial 3: Performance test with custom deployment assets](#tutorial-3-performance-test-with-custom-deployment-assets)
45 - [1. Create new directory](#1-create-new-directory-1)
46 - [2. Create `script.yml`](#2-create-scriptyml)
47 - [3. Understanding `script.yml`](#3-understanding-scriptyml)
48 - [4. Customizing `script.yml`](#4-customizing-scriptyml)
49 - [5. Create custom deployment assets](#5-create-custom-deployment-assets)
50 - [6. Understanding `serverless.yml`](#6-understanding-serverlessyml)
51 - [a. Service name](#a-service-name)
52 - [b. Load generator Lambda function name](#b-load-generator-lambda-function-name)
53 - [c. Load generator Lambda function permissions](#c-load-generator-lambda-function-permissions)
54 - [7. Customizing `serverless.yml`](#7-customizing-serverlessyml)
55 - [a. Customization for Nordstrom Engineers](#a-customization-for-nordstrom-engineers)
56 - [b. Service name](#b-service-name)
57 - [c. Plugins](#c-plugins)
58 - [i. CloudWatch plugin](#i-cloudwatch-plugin)
59 - [ii. Datadog plugin](#ii-datadog-plugin)
60 - [8. Setup AWS account credentials](#8-setup-aws-account-credentials)
61 - [9. Deploy assets to AWS](#9-deploy-assets-to-aws)
62 - [10. Invoke performance test](#10-invoke-performance-test)
63 - [11. Remove assets from AWS](#11-remove-assets-from-aws)
64- [Tutorial 4: Killing in-progress performance test](#tutorial-4-killing-in-progress-performance-test)
65 - [1. Increase `duration`](#1-increase-duration)
66 - [2. Setup AWS account credentials](#2-setup-aws-account-credentials)
67 - [3. Deploy assets to AWS](#3-deploy-assets-to-aws)
68 - [4. Invoke performance test](#4-invoke-performance-test)
69 - [5. Kill the in-progress performance test](#5-kill-the-in-progress-performance-test)
70 - [6. Wait before re-deploying](#6-wait-before-re-deploying)
71- [Performance test workshop](#performance-test-workshop)
72- [Other commands and use cases](#other-commands-and-use-cases)
73 - [Killing in-progress performance test](#killing-in-progress-performance-test)
74 - [Create customized `script.yml`](#create-customized-scriptyml)
75 - [Performance test using script file with different name/path](#performance-test-using-script-file-with-different-namepath)
76 - [Reserved and unsupported flags](#reserved-and-unsupported-flags)
77 - [Reserved flags](#reserved-flags)
78 - [Unsupported flags](#unsupported-flags)
79 - [Providing a data store to view the results of your performance test](#providing-a-data-store-to-view-the-results-of-your-performance-test)
80 - [Related tools and plugins](#related-tools-and-plugins)
81 - [Performance testing VPC hosted services](#performance-testing-vpc-hosted-services)
82 - [Using Payload/CSV files to inject data in scenarios of your `script.yml`](#using-payloadcsv-files-to-inject-data-in-scenarios-of-your-scriptyml)
83 - [Advanced customization use cases](#advanced-customization-use-cases)
84 - [Deployment assets and settings customization](#deployment-assets-and-settings-customization)
85 - [Test script and execution customization using Artillery.io](#test-script-and-execution-customization-using-artilleryio)
86 - [Script splitting customization](#script-splitting-customization)
87 - [Debugging and Tracing Behavior Customization](#debugging-and-tracing-behavior-customization)
88 - [`_trace`](#_trace)
89 - [`_simulation`](#_simulation)
90 - [Splitting and Distribution Logic Customization](#splitting-and-distribution-logic-customization)
91 - [Scripts](#scripts)
92 - [Splitting](#splitting)
93- [Acceptance mode](#acceptance-mode)
94 - [`match` clause](#match-clause)
95 - [Acceptance test command](#acceptance-test-command)
96 - [Tutorial 5: Acceptance mode](#tutorial-5-acceptance-mode)
97 - [1. Customize `script.yml`](#1-customize-scriptyml)
98 - [2. Setup AWS account credentials](#2-setup-aws-account-credentials-1)
99 - [3. Deploy assets to AWS](#3-deploy-assets-to-aws-1)
100 - [4. Invoke acceptance test](#4-invoke-acceptance-test)
101 - [5. Observe the results](#5-observe-the-results)
102 - [6. Test failure scenario](#6-test-failure-scenario)
103 - [6.1. Edit `script.yml` to fail `match`](#61-edit-scriptyml-to-fail-match)
104 - [6.2. Invoke acceptance test](#62-invoke-acceptance-test)
105 - [6.3. Observe the results](#63-observe-the-results)
106 - [7. Remove assets from AWS](#7-remove-assets-from-aws)
107 - [More about acceptance mode](#more-about-acceptance-mode)
108 - [Acceptance testing in CI/CD](#acceptance-testing-in-cicd)
109 - [Run `script.yml` exclusively in acceptance mode](#run-scriptyml-exclusively-in-acceptance-mode)
110 - [Use same `script.yml` for performance and acceptance testing and monitoring](#use-same-scriptyml-for-performance-and-acceptance-testing-and-monitoring)
111 - [To configure acceptance behavior](#to-configure-acceptance-behavior)
112- [Monitoring mode](#monitoring-mode)
113 - [Tutorial 6: Monitoring mode without serverless-artillery alert](#tutorial-6-monitoring-mode-without-serverless-artillery-alert)
114 - [1. Create custom deployment assets](#1-create-custom-deployment-assets)
115 - [2. Setup AWS account credentials](#2-setup-aws-account-credentials-2)
116 - [3. Tryout monitoring mode](#3-tryout-monitoring-mode)
117 - [3.1. Deploy assets to AWS](#31-deploy-assets-to-aws)
118 - [3.2. Invoke monitoring once](#32-invoke-monitoring-once)
119 - [4. Customize deployment assets to turn on monitoring](#4-customize-deployment-assets-to-turn-on-monitoring)
120 - [5. Deploy assets to AWS to start monitoring](#5-deploy-assets-to-aws-to-start-monitoring)
121 - [6. Pause monitoring](#6-pause-monitoring)
122 - [6.1. Method 1: Using CloudWatch Rules](#61-method-1-using-cloudwatch-rules)
123 - [6.2. Method 2: Turn monitoring off in `serverless.yml`](#62-method-2-turn-monitoring-off-in-serverlessyml)
124 - [7. Remove assets from AWS](#7-remove-assets-from-aws-1)
125 - [Tutorial 7: Monitoring mode with serverless-artillery alert](#tutorial-7-monitoring-mode-with-serverless-artillery-alert)
126 - [1. Create custom deployment assets](#1-create-custom-deployment-assets-1)
127 - [2. Setup AWS account credentials](#2-setup-aws-account-credentials-3)
128 - [3. Customize script to have `match` clause](#3-customize-script-to-have-match-clause)
129 - [4. Customize deployment assets to add at least one subscription](#4-customize-deployment-assets-to-add-at-least-one-subscription)
130 - [5. Tryout monitoring mode](#5-tryout-monitoring-mode)
131 - [5.1. Deploy assets to AWS](#51-deploy-assets-to-aws)
132 - [5.2. Invoke monitoring once](#52-invoke-monitoring-once)
133 - [6. Test failure scenario](#6-test-failure-scenario-1)
134 - [6.1. Edit `script.yml` to fail `match`](#61-edit-scriptyml-to-fail-match-1)
135 - [6.2. Invoke monitoring once](#62-invoke-monitoring-once)
136 - [7. Customize deployment assets to turn on monitoring](#7-customize-deployment-assets-to-turn-on-monitoring)
137 - [8. Deploy assets to AWS to start monitoring](#8-deploy-assets-to-aws-to-start-monitoring)
138 - [9. Pause monitoring](#9-pause-monitoring)
139 - [10. Remove assets from AWS](#10-remove-assets-from-aws)
140 - [More about monitoring mode](#more-about-monitoring-mode)
141 - [Run `script.yml` exclusively in monitoring mode](#run-scriptyml-exclusively-in-monitoring-mode)
142 - [Use same `script.yml` for performance and acceptance testing and monitoring](#use-same-scriptyml-for-performance-and-acceptance-testing-and-monitoring-1)
143 - [To configure monitoring behavior](#to-configure-monitoring-behavior)
144- [Detailed Usage](#detailed-usage)
145 - [Commands](#commands)
146 - [`deploy`](#deploy)
147 - [`invoke`](#invoke)
148 - [`kill`](#kill)
149 - [`remove`](#remove)
150 - [`script`](#script)
151 - [`configure`](#configure)
152- [Troubleshooting](#troubleshooting)
153 - [Problems installing?](#problems-installing)
154- [External References](#external-references)
155- [If you've read this far](#if-youve-read-this-far)
156
157# Installation
158
159## Installing on local machine
160You can install serverless-artillery on your local machine as follows.
161### Prerequisite
162#### 1. Node JS
163Before installing serverless-artillery, install Node JS from https://nodejs.org/en/download/ or with your operating system’s package manager. You can install the latest LTS version. We support any version higher than maintenance LTS (v8+).
164#### 2. Serverless Framework CLI
165Before installing serverless-artillery, install Serverless Framework CLI (a.k.a. Serverless) (v1.38+). It should be either installed globally or available in the local node_modules. To install globally use the following command.
166```
167npm install -g serverless
168```
169
170### Installing serverless-artillery
171Now you can install serverless-artillery on your local machine using the following command.
172```
173npm install -g serverless-artillery
174```
175To check that the installation succeeded, run:
176```
177slsart --version
178```
179You should see serverless-artillery print its version if the installation has been successful.
180
181## Installing in Docker
182If you prefer using Docker, refer to [example Dockerfile](Dockerfile) for installation. Please note that, post installation causes permission issues when installing in a Docker image. To successfully install in Docker make sure to add the following to your Dockerfile before the Serverless Framework CLI (a.k.a. Serverless) and serverless-artillery install.
183```
184ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
185ENV PATH=$PATH:/home/node/.npm-global/bin
186```
187
188# Uninstallation
189When needed, you can uninstall serverless-artillery from you local machine using the following command.
190```
191npm uninstall -g serverless-artillery
192```
193
194# How it works?
195<img src="docs/HowItWorks.jpg" width="442">
196
197* Serverless-artillery would be installed and run on your local machine. From command line run `slsart --help` to see various serverless-artillery commands.
198* It takes your JSON or YAML load script (`script.yml`) that specifies
199 * test target/URL/endpoint/service
200 * load progression
201 * and the scenarios that are important for your service to test.
202* When you run `slsart deploy` command, serverless-artillery deploys a **load generator Lambda function**, on your AWS account along with other assets.
203* Running the tests
204 * **Performance test:** When you run `slsart invoke` command, serverless-artillery would invoke the load generator Lambda function.
205 * It would generate the number of requests as specified in `script.yml` to specified test target in order to run the specified scenarios.
206 * **Acceptance test:** When you run `slsart invoke -a` command, serverless-artillery would invoke the load generator Lambda function in acceptance test mode where it runs each scenario in your script exactly once and reports the results.
207 * **Monitoring:** When you customize the deployment assets to turn on monitoring and deploy those assets using `slsart deploy` command, the load generator Lambda function is invoked in monitoring mode once a minute 24x7 where it runs each scenario in your script 5 times and sends an alert if it detects a problem.
208* When you run `slsart remove` command, serverless-artillery would remove these assets from your AWS account.
209* When you run `slsart kill` command, serverless-artillery would kill the in-progress test and remove these assets from your AWS account.
210
211## Technologies powering serverless-artillery
212<details><summary>Click to expand/collapse</summary>
213<p>
214
215### Serverless Framework
216- The [Serverless Framework](https://serverless.com) makes managing (deploying/updating/removing) cloud assets easy.
217- It translates a `yaml` file to deployable assets of the target cloud provider (like AWS).
218- Serverless-artillery uses it to manage required assets to your cloud account.
219
220### Artillery.io
221- [Artillery.io](https://artillery.io/) (built by Hassy Veldstra of shoreditch-ops) is an existing open-source node package, built for easy load testing and functional testing of a target/service/endpoint/URL. It provides a simple but powerful means of specifying how much load to create and what requests that load should comprise.
222- It takes in a developer-friendly JSON or YAML load script that specifies
223 - target/URL/endpoint
224 - load progression
225 - and the scenarios that are important for your service to test.
226- It generates specified load, and measures and reports the resulting latency and return codes.
227- It generates the load by running on your local machine or servers.
228- However, if you specify more load in your script than what can be produced on your machine, artillery will throttle down the load specified in your script. While it is simple to distribute artillery across a fleet of servers, you must then manage, coordinate, and retire them. It is not a serverless solution. This is the task that serverless-artillery steps in to remove from your plate.
229
230### Serverless-artillery
231- Serverless-artillery allows your script to specify an amount of load far exceeding the capacity of a single server to execute.
232- It breaks that script into smaller chunks (sized for a single instance of load generator Lambda function) and distribute the chunks for execution across multiple instances of load generator Lambda function.
233- Since this is done using a FaaS provider, the ephemeral infrastructure used to execute your load disappears as soon as your load tests are complete.
234
235</p>
236</details>
237
238## Load generator Lambda function on AWS
239<details><summary>Click to expand/collapse</summary>
240<p>
241
242<img src="docs/Architecture.gif">
243
244- Serverless-artillery generates the requests to run the specified tests using load generator Lambda function, which is deployed and invoked on AWS along with other assets.
245 - Naming format is `<customized-service-name default:serverless-artillery>-<optional-unique-string-><stage default:dev>-loadGenerator`. For example, `serverless-artillery-dev-loadGenerator` or `serverless-artillery-XnBa473psJ-dev-loadGenerator`.
246- It has an ephimeral architecture. It only exists as long as you need it.
247- It runs Artillery.io node package in AWS Lambda function.
248 - Each lambda function can only generate a certain amount of load, and can only run for up to five minutes (five minutes was a built-in limitation of AWS Lambda. Now it has been raised to 15 minutes).
249 - Given these limitations, it is often necessary to invoke more lambdas - both to scale horizontally (to generate higher load) as well as handing off the work to a new generation of lambdas before their run-time has expired.
250- Above diagram shows how Serverless Artillery solves this problem.
251 - It first runs the Lamdba function in a **controller** mode. It examines the submitted load config JSON/YAML script (this is identical to the original “servered” [Artillery.io](https://artillery.io/) script). This script is also referred to as original script. If the load in the original script exceeds what a single lambda is configured to handle, then the load config is chopped up into workloads achievable by a single lambda.
252 - Controller lambda then invokes as many **worker** lambdas as necessary to generate the load. Controller lambda passes a script to worker lambda that is created by chopping up the original script.
253 - Towards the end of the Lambda runtime the controller lambda invokes a new controller lambda to produce load for the remaining duration.
254- The result of the load test can be reported to CloudWatch, InfluxDB or Datadog through plugins and then visualized with CloudWatch, Grafana or Datadog dashboard.
255
256</p>
257</details>
258
259# Before running serverless-artillery
260Serverless-artillery needs to _deploy_ assets like [load generator Lambda function](#load-generator-lambda-function-on-aws) to AWS, _invoke_ the function to run the tests and _remove_ these assets from AWS when not needed. Hence you need an AWS account and setup credentials with which to deploy, invoke and remove the assets from AWS.
261
262## Setup for Nordstrom Technology
263If you are a **_Nordstrom_** engineer, please see the page titled **_`Serverless Artillery - Nordstrom Technology Setup`_** in **Confluence** and follow the instructions there.
264## Setup for everyone else
265In order to use serverless-artillery, depending on the AWS account environment you're working in, you may need to define `AWS_PROFILE` to declare the AWS credentials to use and possibly `HTTP_PROXY` in order to escape your corporate proxy. See the [Serverless Framework docs](https://serverless.com/framework/docs/) or serverless-artillery workshop's [Lesson 0](https://github.com/Nordstrom/serverless-artillery-workshop/tree/master/Lesson0%20-%20Before%20the%20workshop) followed by [**Step 1** of Lesson 1](https://github.com/Nordstrom/serverless-artillery-workshop/tree/master/Lesson1%20-%20Hello%2C%20artillery#step-1-serverless-artillery-requires-aws-credentials) for details of how to set your local machine for successful deployment, invocation, and removal of assets from your AWS accounts.
266
267# Performance mode (performance/load testing)
268You can use serverless-artillery to performance test or load test your service/target/endpoint/URL. Performance testing framework forms the basis of the other two modes of serverless-artillery, i.e. acceptance mode and monitoring mode.
269
270## Tutorial 1: Run a quick performance test
271If you want to quickly test your setup or see serverless-artillery in action, do the following to quickly run a **small load/performance test**.
272
273### 1. Setup AWS account credentials
274Make sure you have [setup your AWS account credentials](#before-running-serverless-artillery) before proceeding.
275
276### 2. Command line
277Go to command line for all the following steps in this tutorial. You can run the steps of this tutorial from anywhere in command line since the commands you run in this tutorial will not create any files on your local machine.
278
279### 3. Deploy
280The `slsart deploy` command deploys required assets (like [load generator Lambda function](#load-generator-lambda-function-on-aws)) to the AWS account you selected in the previous step.
281
282By _default_ it uses `service` name `serverless-artillery` and `stage` name `dev`. And hence the _default_ AWS CloudFormation Stack name becomes `serverless-artillery-dev` (format: `<service-name default:serverless-artillery>-<stage-name default:dev>`). You will see that if you go to your AWS account console > CloudFormation after running the command.
283
284Since multiple developers could share an AWS account, we recommend creating a unique stack for your use. For that we recommend either using custom deployment assets as shown in [Tutorial 3](#tutorial-3-performance-test-with-custom-deployment-assets) or use the _optional_ `stage` argument as shown in the following command.
285```
286slsart deploy --stage <your-unique-stage-name>
287```
288The AWS CloudFormation Stack name would be `serverless-artillery-<your-unique-stage-name>`.
289
290For example,
291```
292slsart deploy --stage test1
293```
294The AWS CloudFormation Stack name in this case would be `serverless-artillery-test1`.
295
296### 4. Invoke
297The following command will invoke [load generator Lambda function](#load-generator-lambda-function-on-aws) using the default load script (`script.yml`), creating small traffic against the sample endpoint specified in the default script. Note that this default load script is part of the global install of serverless-artillery and not in the local folder from where you are running the command.
298```
299slsart invoke --stage <your-unique-stage-name>
300```
301At the end of the test serverless-artillery will generate a report of the test. **Please note that this report is generated only for small load.** See [here](#providing-a-data-store-to-view-the-results-of-your-performance-test) for details.
302
303If you go to AWS Lambda console > find the `loadGenerator` Lambda corresponding to your stack > `Monitoring` tab > `Invocations` graph, you will see that the Lambda function was invoked to generate the load. You can also see the logs produced by the Lambda in CloudWatch Logs.
304
305### 5. Remove
306The following command will remove the AWS CloudFormation Stack deployed in step 3. If you are a **_Nordstrom_** engineer, please see the page titled **_`Serverless Artillery - Remove Instructions`_** in **Confluence** and follow the instructions there.
307```
308slsart remove --stage <your-unique-stage-name>
309```
310
311## Tutorial 2: Performance test with custom script
312Throughout this tutorial we will walk you towards performance testing the AWS website, https://aws.amazon.com/.
313
314We would test with our _custom_ script but would use _default_ deployment assets.
315
316### 1. Create new directory
317Start by creating a new directory for this tutorial and go to that directory in command line.
318
319### 2. Create `script.yml`
320Serverless-artillery needs to know information about the performance test that user wants to run. It needs information like, the target URL of the service that user wants to test, load progression, user's interaction with the service (scenarios) etc. All these are described in a `yml` file. It is the same `yml` that Artillery.io uses.
321- **Please see [here for basic concepts for Artillery.io usage](https://artillery.io/docs/basic-concepts/#basic-concepts).**
322- **Please see [here for Artillery.io's test script reference](https://artillery.io/docs/script-reference/).**
323
324Run the following command to create the initial `script.yml` file.
325```
326slsart script
327```
328
329### 3. Understanding `script.yml`
330Open `script.yml` with your favorite editor to see what it contains.
331<details><summary>Click to expand/collapse</summary>
332<p>
333
334```
335# Thank you for trying serverless-artillery!
336# This default script is intended to get you started quickly.
337# There is a lot more that Artillery can do.
338# You can find great documentation of the possibilities at:
339# https://artillery.io/docs/
340config:
341 # this hostname will be used as a prefix for each URI in the flow unless a complete URI is specified
342 target: "http://aws.amazon.com"
343 phases:
344 -
345 duration: 5
346 arrivalRate: 2
347scenarios:
348 -
349 flow:
350 -
351 get:
352 url: "/"
353
354```
355
356</p>
357</details>
358
359- The script has [`config` block](https://artillery.io/docs/script-reference/#the-config-section)
360 - under which it specifies http://aws.amazon.com as the `target` for the test
361 - and that requests should be made using [HTTP protocol](https://artillery.io/docs/http-reference/)
362 - There is one [load `phase`](https://artillery.io/docs/script-reference/#load-phases) of `duration` of 5 sec and `arrivalRate` of 2 new virtual users arriving every second.
363- The script has [`scenarios` block](https://artillery.io/docs/script-reference/#scenarios)
364 - which contains one scenario
365 - which contains one flow
366 - which has one [flow action](https://artillery.io/docs/http-reference/#flow-actions) to send [GET request](https://artillery.io/docs/http-reference/#get-post-put-patch-delete-requests) for the specified `target`.
367
368### 4. Customizing `script.yml`
369This step is optional in the tutorial. If you like you can customize `script.yml` as follows.
370- If you have a public endpoint/service/URL that you would like to load test then you can change `target` to point to that.
371- You can also change the [load `phase`](https://artillery.io/docs/script-reference/#load-phases) and [`scenarios` block](https://artillery.io/docs/script-reference/#scenarios) as per your need. We recommend using a low load to try the tool first.
372
373### 5. Setup AWS account credentials
374Make sure you have [setup your AWS account credentials](#before-running-serverless-artillery) before proceeding.
375
376### 6. Deploy assets to AWS
377This section is same as before. See [here](#3-deploy) for details.
378
379### 7. Invoke performance test
380Now you are all set to invoke performance test using following command.
381```
382slsart invoke --stage <your-unique-stage-name>
383```
384
385At the end of the test serverless-artillery will generate a report of the test. **Please note that this report is generated only for small load.** See [here](#providing-a-data-store-to-view-the-results-of-your-performance-test) for details.
386
387If you go to AWS Lambda console > find the `loadGenerator` Lambda corresponding to your stack > `Monitoring` tab > `Invocations` graph, you will see that the Lambda function was invoked to generate the load. You can also see the logs produced by the Lambda in CloudWatch Logs.
388
389**NOTE** that for performance testing, the command will take the `script.yml` from your local machine (and not the one deployed in AWS account) to run the performance test. Hence if you edit it on your local machine after deploying assets to AWS, you don't need to deploy again in order to run the performance test again. Also note that this is true only for performance test and acceptance test and not monitoring.
390
391### 8. Remove assets from AWS
392After the test is done, you can remove the assets from AWS using following command. If you are a **_Nordstrom_** engineer, please see the page titled **_`Serverless Artillery - Remove Instructions`_** in **Confluence** and follow the instructions there.
393```
394slsart remove --stage <your-unique-stage-name>
395```
396
397## Tutorial 3: Performance test with custom deployment assets
398
399Throughout this tutorial we will walk you towards performance testing the AWS website, https://aws.amazon.com/.
400
401We would test with our _custom_ script and _custom_ deployment assets.
402
403### 1. Create new directory
404Start by creating a new directory for this tutorial and go to that directory in command line.
405
406### 2. Create `script.yml`
407This section is same as before. See [here](#2-create-scriptyml) for details.
408
409### 3. Understanding `script.yml`
410This section is same as before. See [here](#3-understanding-scriptyml) for details.
411
412### 4. Customizing `script.yml`
413This section is same as before. See [here](#4-customizing-scriptyml) for details.
414
415### 5. Create custom deployment assets
416Create a _local copy_ of the deployment assets for your customization and then deployment to AWS, using following command. The command generates a local copy of the load generator lambda function code (along with other assets) that can be edited and deployed with your changed settings if needed. It also runs `npm install` after creating local copy of the deployment assets.
417```
418slsart configure
419```
420The important files among other files created by this command are as follows.
421
422|File|Description|
423|:----|:----------|
424|`package.json`|Node.js dependencies for the load generator Lambda. Add Artillery.io plugins you want to use here.|
425|`serverless.yml`|Serverless-artillery's service definition/configuration using Serverless Framework. Change AWS-specific settings here.|
426|`handler.js`|Load generator Lambda code. **EDIT AT YOUR OWN RISK.**|
427
428**Note** that everytime you make changes to these local copy of deployment assets or `serverless.yml` file, you need to redeploy using `slsart deploy` command.
429
430**Note** that if you change `package.json` then you need to run `npm install` and then redeploy using `slsart deploy` command.
431
432### 6. Understanding `serverless.yml`
433`serverless.yml` contains serverless-artillery's service definition/configuration using Serverless Framework.
434
435Open `serverless.yml` with your favorite editor to see what it contains.
436<details><summary>Click to expand/collapse</summary>
437<p>
438
439```
440# We're excited that this project has provided you enough value that you are looking at its code!
441#
442# This is a standard [Serverless Framework](https://www.serverless.com) project and you should
443# feel welcome to customize it to your needs and delight.
444#
445# If you do something super cool and would like to share the capability, please open a PR against
446# https://www.github.com/Nordstrom/serverless-artillery
447#
448# Thanks!
449
450# If the following value is changed, your service may be duplicated (this value is used to build the CloudFormation
451# Template script's name)
452service: serverless-artillery-XnBa473psJ
453
454provider:
455 name: aws
456 runtime: nodejs10.x
457 iamRoleStatements:
458 # This policy allows the function to invoke itself which is important if the script is larger than a single
459 # function can produce
460 - Effect: 'Allow'
461 Action:
462 - 'lambda:InvokeFunction'
463 Resource:
464 'Fn::Join':
465 - ':'
466 -
467 - 'arn:aws:lambda'
468 - Ref: 'AWS::Region'
469 - Ref: 'AWS::AccountId'
470 - 'function'
471 - '${self:service}-${opt:stage, self:provider.stage}-loadGenerator*' # must match function name
472 # This policy allows the function to publish notifications to the SNS topic defined below with logical ID monitoringAlerts
473 - Effect: 'Allow'
474 Action:
475 - 'sns:Publish'
476 Resource:
477 Ref: monitoringAlerts # must match the SNS topic's logical ID
478functions:
479 loadGenerator: # !!Do not edit this name!!
480 handler: handler.handler # the serverlessArtilleryLoadTester handler() method can be found in the handler.js source file
481 timeout: 300 # set timeout to be 5 minutes (max for Lambda)
482 environment:
483 TOPIC_ARN:
484 Ref: monitoringAlerts
485 TOPIC_NAME:
486 'Fn::GetAtt':
487 - monitoringAlerts
488 - TopicName
489 events:
490 - schedule:
491 name: '${self:service}-${opt:stage, self:provider.stage}-monitoring' # !!Do not edit this name!!
492 description: The scheduled event for running the function in monitoring mode
493 rate: rate(1 minute)
494 ########################################################################################################################
495 ### !! BEFORE ENABLING... !!!
496 ### 0. Change `'>>': script.yml` below to reference the script you want to use for monitoring if that is not its name.
497 ### The script must be in this directory or a subdirectory.
498 ### 1. Modify your `script.yml` to provide the details of invoking every important surface of your service, as per
499 ### https://artillery.io/docs
500 ### 2. Add a `match` clause to your requests, specifying your expectations of a successful request. This relatively
501 ### undocumented feature is implemented at: https://github.com/shoreditch-ops/artillery/blob/82bdcdfc32ce4407bb197deff2cee13b4ecbab3b/core/lib/engine_util.js#L318
502 ### We would welcome the contribution of a plugin replacing this as discussed in https://github.com/Nordstrom/serverless-artillery/issues/116
503 ### 3. Modify the `monitoringAlerts` SNS Topic below, uncommenting `Subscription` and providing subscriptions for any
504 ### alerts that might be raised by the monitoring function. (To help you out, we've provided commented-out examples)
505 ### (After all, what good is monitoring if noone is listening?)
506 ### 4. Deploy your new assets/updated service using `slsart deploy`
507 ### 5. [As appropriate] approve the subscription verifications for the SNS topic that will be sent following its creation
508 ########################################################################################################################
509 enabled: false
510 input:
511 '>>': script.yml
512 mode: monitoring
513resources:
514 Resources:
515 monitoringAlerts: # !!Do not edit this name!!
516 Type: 'AWS::SNS::Topic'
517 Properties:
518 DisplayName: '${self:service} Monitoring Alerts'
519# Subscription: # docs at https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-subscription.html
520# - Endpoint: http://<host>/<path> # the endpoint is an URL beginning with "http://"
521# Protocol: http
522# - Endpoint: https://<host>/<path> # the endpoint is a URL beginning with "https://"
523# Protocol: https
524# - Endpoint: <target>@<host> # the endpoint is an email address
525# Protocol: email
526# - Endpoint: <target>@<host> # the endpoint is an email address
527# Protocol: email-json
528# - Endpoint: <phone-number> # the endpoint is a phone number of an SMS-enabled device
529# Protocol: sms
530# - Endpoint: <sqs-queue-arn> # the endpoint is the ARN of an Amazon SQS queue
531# Protocol: sqs
532# - Endpoint: <endpoint-arn> # the endpoint is the EndpointArn of a mobile app and device.
533# Protocol: application
534# - Endpoint: <lambda-arn> # the endpoint is the ARN of an AWS Lambda function.
535# Protocol: lambda
536```
537
538</p>
539</details>
540
541Please refer to [`serverless.yml` documentation](https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/) for details. It defines assets needed for monitoring (turned off by default) as well which we will discuss later.
542#### a. Service name
543- In above `serverless.yml` the `service` name is set to `serverless-artillery-XnBa473psJ`. In your `serverless.yml` the string at the end (`XnBa473psJ`) would be different.
544- This will be the AWS CloudFormation stack name when you run `slsart deploy`. Format of the AWS CloudFormation stack name would be `<service-name default:serverless-artillery>-<stage-name default:dev>`.
545 - If you specify the optional stage name with the deploy command, i.e. `slsart deploy --stage <your-unique-stage-name>`, then the AWS CloudFormation stack name would be `<service-name default:serverless-artillery>-<your-unique-stage-name>`
546- The `slsart configure` command adds a random string at the end of the `service` name so you get a unique stack name that does not conflict with anyone else also deploying to the same AWS account, in case you were to not specify the optional stage name with the deploy command.
547- You can change `service` name to some other unique string as per your need. For example, `serverless-artillery-myperftestservice` or `myloadtestservice`.
548- The rest of the `serverless.yml` refers to the service name by using `${self:service}`.
549
550#### b. [Load generator Lambda function](#load-generator-lambda-function-on-aws) name
551The Serverless Framework automatically names the Lambda function based on the service, stage and function name as follows.
552- The function `loadGenerator` when deployed is named as `${self:service}-${opt:stage, self:provider.stage}-loadGenerator`.
553 - `${self:service}` is name of the service. In this `serverless.yml` it is `serverless-artillery-XnBa473psJ`.
554 - `${opt:stage, self:provider.stage}` will either use `${opt:stage}` or `${self:provider.stage}`.
555 - `${opt:stage}` refers to the (optional) stage name passed in `slsart deploy [--stage <stage-name>]` command. For example, if you run `slsart deploy --stage prod` then `prod` would be used for `${opt:stage}`.
556 - If no stage name is passed in the deploy command then `${self:provider.stage}` would be used. It is the `stage` name set under `provider` block in the `serverless.yml`. If one is not provided (like in above example) it is set to `dev`. See [here](https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/).
557- In this example function name will be set to `serverless-artillery-XnBa473psJ-dev-loadGenerator` while running `slsart deploy` command (note no stage name specified).
558#### c. [Load generator Lambda function](#load-generator-lambda-function-on-aws) permissions
559- In order to generate load the load generator Lambda needs to invoke itself.
560- The `iamRoleStatements` block in the `serverless.yml` gives the load generator Lambda function to invoke itself (`lambda:InvokeFunction`).
561
562### 7. Customizing `serverless.yml`
563**NOTE:** Except for [one step for **_Nordstrom_** Engineers](#a-customization-for-nordstrom-engineers), all customizations are **optional** in the tutorial.
564
565If you like you can customize `serverless.yml` as follows.
566
567#### a. Customization for Nordstrom Engineers
568If you are a **_Nordstrom_** engineer, please see the page titled **_`Serverless Artillery - Nordstrom Technology Policies`_** in **Confluence** and follow the instructions there.
569
570#### b. Service name
571- You can change `service` name to some other unique string as per your need.
572- For example, `serverless-artillery-myperftestservice` or `myloadtestservice`.
573- Format of the AWS CloudFormation stack name would be `<service-name default:serverless-artillery>-<stage-name default:dev>` after you deploy.
574
575#### c. Plugins
576You can customize the `serverless.yml` to use required tools/plugins mentioned [below](#related-tools-and-plugins).
577
578##### i. CloudWatch plugin
579In this tutorial you can add [artillery-plugin-cloudwatch](https://github.com/Nordstrom/artillery-plugin-cloudwatch) to record test results to [AWS CloudWatch](https://aws.amazon.com/cloudwatch).
5801. To allow the Lambda code to write to CloudWatch, the correct NPM package dependency must be added. This modifies the package.json file to include the necessary dependency.
581```
582npm install --save artillery-plugin-cloudwatch
583```
584
5852. In `script.yml`, at the end of the `config` block (which already exists)
586```
587config:
588```
589add CloudWatch plugin as follows:
590```
591 plugins:
592 cloudwatch:
593 namespace: "<cloud-watch-namespace>"
594```
595For example, you can use
596```
597 namespace: "serverless-artillery-myperftestservice-loadtest"
598```
599
6003. In `serverless.yml`, at the end of the following block (which already exists)
601```
602provider:
603 iamRoleStatements:
604```
605add the following:
606```
607 - Effect: 'Allow'
608 Action:
609 - 'cloudwatch:PutMetricData'
610 Resource:
611 - '*'
612```
613##### ii. Datadog plugin
614In this tutorial you can add [artillery-plugin-datadog](https://www.npmjs.com/package/artillery-plugin-datadog) to record test results to [Datadog](https://www.datadoghq.com/).
615
6161. To allow the Lambda code to write to Datadog, the correct NPM package dependency must be added. This modifies the package.json file to include the necessary dependency.
617```
618npm install --save artillery-plugin-datadog
619```
620
6212. Update the `config` portion of `script.yml` to add Datadog plugin as follows and customize the `host`, `prefix` and `tags` as per your requirement.
622```
623config:
624 plugins:
625 datadog:
626 # Custom hostname (leave blank if not desired)
627 host: ''
628 # Custom metric prefix (example, to 'serverless-artillery')
629 prefix: 'serverless-artillery'
630 # Additional tags for all metrics
631 tags:
632 - 'mode:test'
633```
634
6353. In `serverless.yml`, under `provider` section specify Datadog API key as an environment variable as follows. **NOTE** that you should not save sensitive information like Datadog API Key in plain text in a source control. Below is just for the tutorial.
636```
637provider:
638 environment:
639 DATADOG_API_KEY: "<your-datadog-api-key>"
640```
641
642### 8. Setup AWS account credentials
643This section is same as before. See [here](#before-running-serverless-artillery) for details.
644
645### 9. Deploy assets to AWS
646This section is same as before. See [here](#3-deploy) for details.
647
648You can go to your AWS account console > CloudFormation, and see AWS stack `<service-name default:serverless-artillery>-<stage-name default:dev>` created there depending on the customizations explained in the steps above.
649
650### 10. Invoke performance test
651This section is same as before. See [here](#7-invoke-performance-test) for details.
652
653If you used CloudWatch/Datadog plugins you will be able to view the metrics on the CloudWatch/Datadog dashboard. You can learn more about using CloudWatch dashboard [here](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html). **Note that it can take few minutes for the data to propogate to CloudWatch/Datadog.**
654
655### 11. Remove assets from AWS
656This section is same as before. See [here](#8-remove-assets-from-aws) for details.
657
658## Tutorial 4: Killing in-progress performance test
659While running performance/load test it is sometimes necessary to kill the test before it is complete. Read more about the [kill command](#killing-in-progress-performance-test).
660
661### 1. Increase `duration`
662If you are a **_Nordstrom_** engineer, please follow [Tutorial 3](#tutorial-3-performance-test-with-custom-deployment-assets) to create custom script and custom deployment assets. Make sure you do [customization for Nordstrom Engineers](#a-customization-for-nordstrom-engineers). Other optional customizations are not necessary for this tutorial.
663
664Others can follow [Tutorial 2](#tutorial-2-performance-test-with-custom-script) to create custom `script.yml`.
665
666Edit `script.yml` in your favorite editor and increase the `duration` to `60` seconds.
667
668### 2. Setup AWS account credentials
669This section is same as before. See [here](#before-running-serverless-artillery) for details.
670
671### 3. Deploy assets to AWS
672This section is same as before. See [here](#3-deploy) for details.
673
674### 4. Invoke performance test
675This section is same as before. See [here](#7-invoke-performance-test) for details.
676
677### 5. Kill the in-progress performance test
678Run the following command to kill the performance test. Read more about the kill command [here](#killing-in-progress-performance-test). **Note** that _kill_ command will also _remove_ the deployed assets. Hence running `slsart remove` after this is not needed.
679```
680slsart kill --stage <your-unique-stage-name> --region=<region-used-for-deploy>
681```
682
683You must specify a `region` when running this command:
684- Use `--region` option, e.g. `--region=us-east-1`
685- or set AWS_REGION in environment, e.g. `AWS_REGION=us-east-1`
686- or configure a default region using the guide below.
687Serverless will use the `us-east-1` region by default.
688
689### 6. Wait before re-deploying
690Wait for ~5 minutes before re-deploying to let the Lambda invocation queue drain.
691
692## Performance test workshop
693We've created a workshop detailing end-to-end usage of serverless-artillery for performance testing. Check out our conference-style [workshop](https://github.com/Nordstrom/serverless-artillery-workshop) for step by step lessons on how to set your system up for successful deployment, invocation, and removal.
694
695## Other commands and use cases
696### Killing in-progress performance test
697While running performance/load test it is sometimes necessary to kill the test before it is complete. For example, it might be done when the test target is not able to handle the current load and you want to stop the test before the service goes down.
698
699You can run the following command to kill the performance test.
700```
701slsart kill --stage <your-unique-stage-name> --region=<region-used-for-deploy>
702```
703You must specify a `region` when running this command:
704- Use `--region` option, e.g. `--region=us-east-1`
705- or set AWS_REGION in environment, e.g. `AWS_REGION=us-east-1`
706- or configure a default region using the guide below.
707Serverless will use the `us-east-1` region by default.
708
709The command will do the followings:
710- It will set the load generator Lambda function's [concurrency level](https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html#per-function-concurrency) to 0.
711- and then _remove_ the deployed assets. It will remove load generator Lambda function, CloudWatch logs, and IAM role. CloudWatch metrics will remain.
712
713Result:
714- Any further invocations of load generator Lambda will be supressed.
715- The already executing instances of load generator Lambda will continue and complete the assigned load generation workload.
716- The load generator Lambda function by default runs for up to 2 minutes. So that would be the default maximum time before the load generation stops.
717
718**You will want to wait approximately 5 minutes before redeploying to avoid the killed performance test from resuming.** Behind the scenes, AWS creates a queue for Lambda invocations. While processing the invocation requests from the queue, if a function is not available then that message will be placed back onto the queue for further attempts. As a result, redeploying your function can allow those re-queued messages to be used to invoke your re-deployed function. In our observation based on a limited set of tests, messages will be permanently failed out of the queues after 5 minutes. That is the basis of our recommendation.
719
720The default maximum duration of a [script chunk](#splitting) is 2 minutes (`maxChunkDurationInSeconds`). As a result of this, on average, load will not be produced after 1 minute but it could continue for up to the full 2 minutes. To lower the wait times after killing, this value can be overridden in your `script.yml` within the \_split attribute, as shown [here](#script-splitting-customization). This value can be as low as 15 seconds and using this value causes each script chunk to run for a maximum duration of 15 seconds. Theoretically, this means that you’d only have to wait 7.5 seconds on average for tests to stop running after killing your test (in practice we have observed roughly 20 seconds lag between killing a function and termination of invocations).
721
722### Create customized `script.yml`
723Above you used how to use `slsart script` to create the default `script.yml` (see [here](#2-create-scriptyml)) and how to customize it by manually editing it (see [here](#4-customizing-scriptyml)).
724
725`slsart script` command has options to quickly do the above in one command. Run the following command to create custom `script.yml` with **one** load `phase`.
726```
727slsart script -e <your-target-endpoint> -d <duration-in-sec> -r <arrival-rate-in-virtual-users-arriving-per-second> -t <ramp-to-in-virtual-users-arriving-per-second>
728```
729
730For example, following command will create a `script.yml` with test target https://example.com, performance test starting with 10 requests per second, and scaling up to 25 requests per second, over a duration of 60 seconds.
731```
732slsart script -e https://example.com -d 60 -r 10 -t 25
733```
734
735For more details see
736```
737slsart script --help
738```
739
740### Performance test using script file with different name/path
741The `slsart script` command by default gives the file name `script.yml`. If you want to give a different name to your `yml` file then you can use the `-o` option of the `slsart script` command. See`slsart script --help` for more details.
742```
743slsart script -o <preferred-filename.yml>
744```
745Example,
746```
747slsart script -o myservicetests.yml
748```
749
750By default `slsart invoke` command will look for `script.yml` under the local folder to run performance test. You can use `-p` option to specify script file with different name/path as follows.
751```
752slsart invoke -p <path-to-your-script-file>
753```
754For example, following command will *invoke* performance test using the specified file.
755```
756slsart invoke -p /my/path/to/myotherscript.yml
757```
758
759For more options see,
760```
761slsart invoke --help
762```
763
764### Reserved and unsupported flags
765`slsart` commands support most commandline flags of the corresponding `sls` (Serverless Framework) commands.
766#### Reserved flags
767Following flags are reserved in `slsart invoke` command.
768- The flags `-t`, `--type`, `-f`, and `--function` are reserved for `serverless-artillery` use. They cannot be supplied on the command line.
769- The `-t` and `--type` flags are reserved because the tool uses the script you provide it to cacluate whether an `Event` or `RequestResponse` invocation type is more appropriate. If that argument was supplied, a user might have an expectation-behavior mismatch.
770- The `-f` and `--function` flags are reserved because a part of the value that `serverless-artillery` provides is the automated definition of the function providing load testing and thereby a necessarily strong opinion of the name that function was given.
771#### Unsupported flags
772The flag `--raw` is unsupported in `slsart invoke` command because, while arbitrary functions can accept strings, a string does not comprise a valid artillery script.
773
774### Providing a data store to view the results of your performance test
775- If your script specifies a small load that can be generated by single invocation of [load generator Lambda function](#load-generator-lambda-function-on-aws) then the results are reported back at the end of `slsart invoke` command.
776- Otherwise, the volume of load results can be such that it cannot pass back to the original requestor.
777- You are responsible for sending the results (usually via a plugin) to a data store for later review and/or analysis. See the [available plugins](#related-tools-and-plugins) that can be used.
778
779### Related tools and plugins
780You would need to [create custom deployment assets](#tutorial-3-performance-test-with-custom-deployment-assets) and customize `serverless.yml` to use a plugin as shown in the examples [here](#c-plugins).
781
782|Plugin|Description|
783|:----|:----------|
784|[artillery-plugin-aws-sigv4](https://github.com/Nordstrom/artillery-plugin-aws-sigv4)|for testing against an authenticated AWS API Gateway endpoint.|
785|[artillery-plugin-influxdb](https://github.com/Nordstrom/artillery-plugin-influxdb)|to record test results to InfluxDB.|
786|[artillery-plugin-cloudwatch](https://github.com/Nordstrom/artillery-plugin-cloudwatch)|to record test results to AWS CloudWatch.|
787|[artillery-plugin-datadog](https://www.npmjs.com/package/artillery-plugin-datadog)|to record test results to DataDog.|
788|[serverless-attach-managed-policy](https://www.npmjs.com/package/serverless-attach-managed-policy)|if you have automatic IAM role modification in your corporate/shared AWS account.|
789
790### Performance testing VPC hosted services
791The default deployment assets (used in [Tutorial 1](#tutorial-1-run-a-quick-performance-test) and [Tutorial 2](#tutorial-2-performance-test-with-custom-script)) of serverless-artillery are not deployed in a VPC and hence it can only successfully send requests to public endpoints. If your service is hosted in VPC (i.e. service is internal and does not have public endpoint), you would need to use [custom deployment assets](#tutorial-3-performance-test-with-custom-deployment-assets).
792
793Please refer to Serverless Frameworks's [doc](https://serverless.com/framework/docs/providers/aws/guide/functions/#vpc-configuration) to understand how to customize `serverless.yml` to deploy the customized assets to VPC.
794
795You need to add following section to your `serverless.yml` and add appropriate `securityGroupIds` and `subnetIds`.
796```
797provider:
798 name: aws
799 vpc:
800 securityGroupIds:
801 - securityGroupId1
802 - securityGroupId2
803 subnetIds:
804 - subnetId1
805 - subnetId2
806```
807
808### Using Payload/CSV files to inject data in scenarios of your `script.yml`
809- For some scenarios it can be useful to pass different information (example, user ID and password, search term) in the requests sent. Artillery.io allows you to use payload file to accomplish that. Please refer to Artillery.io's [doc](https://artillery.io/docs/script-reference/#payload-files) to understand how to customize `script.yml` to use payload/CSV files.
810- You would need to use [custom deployment assets](#tutorial-3-performance-test-with-custom-deployment-assets) to use payload files in serverless-artillery.
811- The payload/CSV files should be under the same directory as `serverless.yml`.
812- Payload files are deployed with the load generator Lambda. You would need to redeploy everytime it is changed (unlike `script.yml`).
813- **Payload file size limitation**
814 - As mentioned above, payload files are deployed with load generator Lambda.
815 - AWS Lambda poses a limitation on how large of a payload file can be deployed with it. See [here](https://docs.aws.amazon.com/lambda/latest/dg/limits.html)
816 - Artillery.io allows the script to read from payload files in `random` or `sequence` `order`. For that it loads the entire payload file in memory. Hence Lambda memory size limitation would also determine how large of a payload file can be used.
817 - If your payload file is too large, you may need to write some custom code (i.e. write a custom processor or modify the serverless-artillery codebase) that will retrieve the data from S3 for you prior to the execution of any load.
818
819### Advanced customization use cases
820#### Deployment assets and settings customization
821- Above we discussed how you need to use [custom deployment assets](#tutorial-3-performance-test-with-custom-deployment-assets) and [`slsart configure` command] (#5-create-custom-deployment-assets) when your testing needs are not met by the default deployment assets that are used in [Tutorial 1](#tutorial-1-run-a-quick-performance-test) and [Tutorial 2](#tutorial-2-performance-test-with-custom-script).
822- For example,
823 - when the endpoints you need to test are in the VPC. See [here](#performance-testing-vpc-hosted-services) for details.
824 - when you need to view the results in your data store. See [here](#providing-a-data-store-to-view-the-results-of-your-performance-test) for details.
825 - when you need to automatically attach an AWS Managed IAM Policy (or Policies) to all IAM Roles created by serverless-artillery due to company policy. See `serverless-attach-managed-policy` plugin [here](#related-tools-and-plugins) for details.
826 - when you need to separate out various versions of the load testing function in order to maintain least privilege.
827 - when you want to use payload/CSV files to feed data into the request being sent to the target. See [here](#using-payloadcsv-files-to-inject-data-in-scenarios-of-your-scriptyml) for details.
828 - when you want to add custom IAM rights (see Serverless Framework [docs](https://serverless.com/framework/docs/providers/aws/guide/iam/)) to the load generator Lambda to validate least privilege.
829- For such cases you need to create a local copy of the deployment assets using [`slsart configure` command](#5-create-custom-deployment-assets), customize them for your use case and deploy them using `slsart deploy` command as shown in [Tutorial 3](#tutorial-3-performance-test-with-custom-deployment-assets).
830- Full documentation of what is in the `serverless.yml` and the options you have available can be found at https://serverless.com/framework/docs/.
831- You would need to use custom deployment assets when you want to make even more customizations to how serverless-artillery works. [`slsart configure` command](#5-create-custom-deployment-assets) generates a local copy of the serverless function code that can be edited and redeployed with your changed settings. For example, if you need to make any code change to load generator Lambda (example, alter hard-coded limits).
832- Please see [Serverless Framework docs](https://serverless.com/framework/docs/providers/aws/) for load generation Lambda function's configuration related documentation.
833- Please see [Artillery.io docs](https://artillery.io/docs/script-reference/) for script configuration related documentation.
834- **Note** that everytime you make changes to the local copy of deployment assets, you need to redeploy using `slsart deploy` command.
835
836#### Test script and execution customization using Artillery.io
837- The test script, `script.yml`, allows you to add plugins for various capabilities. For example,
838 - when you need to test against an authenticated AWS API Gateway endpoint. See `artillery-plugin-aws-sigv4` plugin [here](#related-tools-and-plugins) for details.
839 - when you need to view the results in your data store. See [here](#providing-a-data-store-to-view-the-results-of-your-performance-test) for details.
840- Also see [Artillery.io's plugin docs](https://github.com/artilleryio/artillery/blob/master/docs/plugins.md) about how to write your plugin.
841- You can also use payload/CSV files to feed data into the request being sent to the target. See [here](#using-payloadcsv-files-to-inject-data-in-scenarios-of-your-scriptyml) for details.
842- The HTTP engine has support for "hooks", which allow for custom JS functions to be called at certain points during the execution of a scenario. See [here](https://artillery.io/docs/http-reference/#advanced-writing-custom-logic-in-javascript) for details.
843
844#### Script splitting customization
845As mentioned [here](#load-generator-lambda-function-on-aws), the controller mode load generator Lambda function splits the work to generate the required load between multiple worker mode load generator Lambdas. The following controls are available to control how splitting is done. That said, the defaults are good and you generally won't need them until you have gotten deeper into implementation.
846To use these, define a `_split` attribute within your `script.yml`. The values of that object will be used to alter the splitting of your script.
847```
848{
849 _split: {
850 maxScriptDurationInSeconds: 86400, # Default listed. Hard-coded max is 518400
851 maxChunkDurationInSeconds: 120, # Default listed. Hard-coded max is 285, min is 15
852 maxScriptRequestsPerSecond: 5000, # Default listed. Hard-coded max is 50000
853 maxChunkRequestsPerSecond: 25, # Default listed. Hard-coded max is 500
854 timeBufferInMilliseconds: 15000, # Default listed. Hard-coded max is 30000
855 }
856 ...
857}
858```
859See the [Splitting and Distribution Logic Customization](#splitting-and-distribution-logic-customization) section for an in depth discussion of how splitting is implemented and what you control with these parameters as well as the concerns involved in making decisions about them. See the comments in [`~/lambda/handler.js`](lib/lambda/handler.js) for detailed documentation of the semantics the code has with regard to them (search for '`const constants`'). By the way, you now have the source code to change those hard-coded limits and can change them at will if you so desire - we wanted to provide a margin of safety and guardrails but not restrictions.
860
861#### Debugging and Tracing Behavior Customization
862There are two primary tools for debugging and tracing the load generator Lambda function and how it splits and executes the task it has been given. Define the following in your `script.yml`:
863```
864{
865 _trace: true,
866 _simulation: true,
867 ...
868}
869```
870
871##### `_trace`
872`_trace` causes the load generator Lambda function to report the actions it is taking with your script and the chunks that it breaks your script into. Expect statements such as this:
873```
874scheduling self invocation for 1234567890123 in 2345678901234 with a 3456789012345 ms delay
875```
876
877This would be produced by the following line in the source code:
878```
879console.log(`scheduling self invocation for ${event._genesis} in ${event._start} with a ${timeDelay} ms delay`);
880```
881
882Here are definitions that will help you understand these statements. In the code you will see `_genesis`, `_start`, `now`, and `timeDelay`:
883- `_genesis`: the datetime stamp immediately taken by the first instance of load generator Lambda function that received the original script. `_genesis` is added to the original script so that all child function executions of the original handler have a datetime stamp of when the original "load execution request" was received. If you are not running many load tests simultaneously then this can serve as a unique ID for the current load execution. This can be useful for correlation. An improvement could include adding a unique factor to avoid collisions in such usage.
884- `_start`: the datetime stamp immediately taken by the current function that is executing on either the original script or a chunk of that original script. This allows relative time reporting and evaluation with a function execution.
885- `now`: the datetime stamp taken when the log entry was produced.
886- `timeDelay`: a time delta (in milliseconds) between the current time of the current function and when it has scheduled to take the action reported in the current log entry.
887
888`_trace` is very useful in identifying what the system is doing or where something is going wrong. #bugs-happen
889
890##### `_simulation`
891Setting the `_simulation` attribute to a truthy value will cause the load generator Lambda function to split the script without taking action on the script. Functionally, this comprises splitting the given script into pieces without invoking functions to handle the split chunks and/or execute the load described by those chunks. Concretely, when it comes time to invoke new function instances for distributing the load, it simply invokes (or schedules an invokation of) itself. Likewise, when it comes time to invoke the `artillery` entry point for generator load from the chunk, it instead invokes the simulation shim that reports what would have been executed and immediately completes.
892
893This mode, in combination with `_trace` related behavior is very helpful in debugging script splitting behavior and identifying what the logic declares should occur.
894
895#### Splitting and Distribution Logic Customization
896You've got the code. Have at! Have fun and consider contributing improvements back into the tool. Thank you!
897
898Some helpful notions used in the code and discussion of them follows.
899##### Scripts
900An artillery script is composed of a number of phases which occur one after the other. Each of these phases has its own duration and maximum load. The duration is straightforwardly how long the phase lasts. The maximum load of the phase is the maximum Requests Per Second (RPS) that are declared for the entirety of that phase (e.g. a phase declaring a ramp up from 0 to 500 RPS has a maximum load of 500 RPS). Phases are declared in serial in order to provide warming or not as appropriate for the load testing scenario that interests you.
901
902The duration of the script is the sum of the durations of its phases. The maximum load of the script is the maximum RPS that any of its phases declares.
903
904##### Splitting
905The splitting of a script comprises taking "chunks" off of the script.
906
907First, we take chunks from the script by duration. This is driven by the maximum duration of the underlying function as a service (FaaS) provider that we are using. For AWS Lambda, this at the time of original implementation was 5 minutes (now 15 minutes). However, we need to allow for cold starts and as such must provide a buffer of time before we begin the execution of any specific load job. Following the execution of a load job, the artillery framework calculates a summary and invokes custom analyzers (via the plugin capabilities it offers). As a result, a tailing buffer is also needed to ensure execution can properly complete.
908
909The result is a script chunk that can be executed within the duration limited period the FaaS provider allows (no guarantees yet exist on whether a single function can execute the demanded load). This chunk will be called the script for referential simplicity. We also may have a remainder script that must be executed by a new function instance as the current splitting function nears its timeout.
910
911Next, we take chunks from the script by maximum load. This is driven by the maximum requests per second that a single execution of the underlying function as a service (FaaS) provider is capable of pushing with high fidelity. For AWS Lambda (with the default 1024 MB configuration), we found 25 RPS to be a good level. This is lower than the absolute ceiling that Lambda is capable of pushing for a reason. First, each connection will be a separate opened and closed socket. Second, if we are producing too many connections, we can be in the middle of making a request when we receive the response of a separate request. Given that this is implemented in NodeJS, we have one thread and that means the timestamping of the receipt of that response is artificially and incorrectly delayed. We found that at RPS above 25 we observed an increase in the volatility of observed latencies. That written, if you do not intend to record your latencies, then you could bump this up to the limit of the FaaS service (i.e. `_split.maxChunkRequestsPerSecond = 300` or so).
912
913The result is a script chunk that is less than the limited period and also executable by a single function instance. Therefore, we invoke a single function with the chunk to execute it.
914
915# Acceptance mode
916Find defects before performance testing! Acceptance mode runs each scenario/flow in your script exactly once and reports the results. For example, you can run your script in acceptance mode in your CI/CD to ensure that merges don't break the scenarios in your script.
917
918Performance testing framework forms the basis of acceptance mode of serverless-artillery. Hence please go through [performance mode](#performance-mode-performanceload-testing) section before proceeding.
919
920## `match` clause
921Ensure that you have `match` clauses defined for each request in your script's flows to validate the responses. You can read about how to use `match` in [Artillery.io docs](https://artillery.io/docs/http-reference/?#extracting-and-reusing-parts-of-a-response-request-chaining) and ["official" docs](https://github.com/shoreditch-ops/artillery/blob/master/core/lib/engine_util.js#L318). Also see, [serverless-artillery issue #116](https://github.com/Nordstrom/serverless-artillery/issues/116).
922
923## Acceptance test command
924When `-a` option is used in `slsart invoke` command, serverless-artillery invokes the load generator Lambda in acceptance mode.
925```
926slsart invoke -a
927```
928Expect a non-zero exit code if a match clause fails.
929
930## Tutorial 5: Acceptance mode
931### 1. Customize `script.yml`
932Follow [Tutorial 2 to create custom `script.yml`](#tutorial-2-performance-test-with-custom-script) and customize your `script.yml` by copy pasting the following content in it. Note the `match` clauses.
933
934```
935# Thank you for trying serverless-artillery!
936# This default script is intended to get you started quickly.
937# There is a lot more that Artillery can do.
938# You can find great documentation of the possibilities at:
939# https://artillery.io/docs/
940config:
941 # this hostname will be used as a prefix for each URI in the flow unless a complete URI is specified
942 target: "https://postman-echo.com/headers"
943 phases:
944 -
945 duration: 1
946 arrivalRate: 1
947 defaults:
948 headers:
949 my-sample-header: "my-sample-header-value"
950scenarios:
951 -
952 flow:
953 -
954 get:
955 url: "/"
956 match:
957 - json: "$.headers.my-sample-header"
958 value: "my-sample-header-value"
959 #value: "failvalue"
960 - json: "$.headers.host"
961 value: "postman-echo.com"
962 #value: "failvalue"
963 - json: "$.headers.x-forwarded-proto"
964 value: "https"
965 #value: "failvalue"
966```
967
968The script is using target `https://postman-echo.com/headers` which at the time of writing this document is designed to return JSON response with headers that are passed in the request.
969
970Run the following to try that out.
971```
972curl --location --request GET "https://postman-echo.com/headers" --header "my-sample-header: my-sample-header-value"
973```
974
975The JSON response will be as follows.
976```
977{
978 "headers": {
979 "x-forwarded-proto": "https",
980 "host": "postman-echo.com",
981 "accept": "*/*",
982 "my-sample-header": "my-sample-header-value",
983 "user-agent": "curl/7.54.0",
984 "x-forwarded-port": "443"
985 }
986}
987```
988
989The `match` clauses check if the return value is same as what is expected.
990
991### 2. Setup AWS account credentials
992This section is same as before. See [here](#before-running-serverless-artillery) for details.
993
994### 3. Deploy assets to AWS
995This section is same as before. See [here](#3-deploy) for details.
996
997**Note** that you don't need to _deploy_ the assets everytime `script.yml` changes.
998
999### 4. Invoke acceptance test
1000Run following command to run acceptance test.
1001```
1002slsart invoke -a --stage <your-unique-stage-name>
1003```
1004
1005### 5. Observe the results
1006You will see an output similar to the following.
1007<details><summary>Click to expand/collapse</summary>
1008<p>
1009
1010```
1011
1012 Invoking test Lambda
1013
1014{
1015 "errors": 0,
1016 "reports": [
1017 {
1018 "timestamp": "2019-04-17T21:40:59.127Z",
1019 "scenariosCreated": 1,
1020 "scenariosCompleted": 1,
1021 "requestsCompleted": 1,
1022 "latency": {
1023 "min": 26.6,
1024 "max": 26.6,
1025 "median": 26.6,
1026 "p95": 26.6,
1027 "p99": 26.6
1028 },
1029 "rps": {
1030 "count": 1,
1031 "mean": 2.7
1032 },
1033 "scenarioDuration": {
1034 "min": 177.8,
1035 "max": 177.8,
1036 "median": 177.8,
1037 "p95": 177.8,
1038 "p99": 177.8
1039 },
1040 "scenarioCounts": {
1041 "0": 1
1042 },
1043 "errors": {},
1044 "codes": {
1045 "200": 1
1046 },
1047 "matches": 3,
1048 "customStats": {},
1049 "phases": [
1050 {
1051 "pause": 0.2430741319294641
1052 },
1053 {
1054 "duration": 1,
1055 "arrivalRate": 1
1056 }
1057 ]
1058 }
1059 ],
1060 "totals": {
1061 "scenariosCreated": 1,
1062 "scenariosCompleted": 1,
1063 "requestsCompleted": 1,
1064 "codes": {
1065 "200": 1
1066 },
1067 "errors": {}
1068 }
1069}
1070
1071 Your function invocation has completed.
1072
1073{
1074 "errors": 0,
1075 "reports": [
1076 {
1077 "timestamp": "2019-04-17T21:40:59.127Z",
1078 "scenariosCreated": 1,
1079 "scenariosCompleted": 1,
1080 "requestsCompleted": 1,
1081 "latency": {
1082 "min": 26.6,
1083 "max": 26.6,
1084 "median": 26.6,
1085 "p95": 26.6,
1086 "p99": 26.6
1087 },
1088 "rps": {
1089 "count": 1,
1090 "mean": 2.7
1091 },
1092 "scenarioDuration": {
1093 "min": 177.8,
1094 "max": 177.8,
1095 "median": 177.8,
1096 "p95": 177.8,
1097 "p99": 177.8
1098 },
1099 "scenarioCounts": {
1100 "0": 1
1101 },
1102 "errors": {},
1103 "codes": {
1104 "200": 1
1105 },
1106 "matches": 3,
1107 "customStats": {},
1108 "phases": [
1109 {
1110 "pause": 0.2430741319294641
1111 },
1112 {
1113 "duration": 1,
1114 "arrivalRate": 1
1115 }
1116 ]
1117 }
1118 ],
1119 "totals": {
1120 "scenariosCreated": 1,
1121 "scenariosCompleted": 1,
1122 "requestsCompleted": 1,
1123 "codes": {
1124 "200": 1
1125 },
1126 "errors": {}
1127 }
1128}
1129Results:
1130PASSED
1131```
1132
1133</p>
1134</details>
1135
1136You can observe the following in the result:
1137- Observe the following section where we list the number of scenarios created, scenarios completed, requests completed and list of errors which in this case is 0.
1138```
1139 "totals": {
1140 "scenariosCreated": 1,
1141 "scenariosCompleted": 1,
1142 "requestsCompleted": 1,
1143 "codes": {
1144 "200": 1
1145 },
1146 "errors": {}
1147```
1148
1149Also, as this test passed, you will also observe that the process exit code is 0. On _Mac_ you can run command `echo $?` immediately after that to see the process exit code 0 in this case.
1150
1151### 6. Test failure scenario
1152#### 6.1. Edit `script.yml` to fail `match`
1153Edit `match` section in `script.yml` to look for wrong return value to simulate failure scenario. Note that we are causing failure for two matches out of three.
1154```
1155 match:
1156 - json: "$.headers.my-sample-header"
1157 value: "my-sample-header-value"
1158 #value: "failvalue"
1159 - json: "$.headers.host"
1160 #value: "postman-echo.com"
1161 value: "failvalue"
1162 - json: "$.headers.x-forwarded-proto"
1163 #value: "https"
1164 value: "failvalue"
1165```
1166#### 6.2. Invoke acceptance test
1167Invoke acceptance test as mentioned [above](#4-invoke-acceptance-test).
1168
1169#### 6.3. Observe the results
1170You will see an output similar to the following.
1171<details><summary>Click to expand/collapse</summary>
1172<p>
1173
1174```
1175
1176 Invoking test Lambda
1177
1178{
1179 "errors": 2,
1180 "reports": [
1181 {
1182 "timestamp": "2019-04-17T21:56:59.527Z",
1183 "scenariosCreated": 1,
1184 "scenariosCompleted": 0,
1185 "requestsCompleted": 1,
1186 "latency": {
1187 "min": 24.7,
1188 "max": 24.7,
1189 "median": 24.7,
1190 "p95": 24.7,
1191 "p99": 24.7
1192 },
1193 "rps": {
1194 "count": 1,
1195 "mean": 2
1196 },
1197 "scenarioDuration": {
1198 "min": null,
1199 "max": null,
1200 "median": null,
1201 "p95": null,
1202 "p99": null
1203 },
1204 "scenarioCounts": {
1205 "0": 1
1206 },
1207 "errors": {
1208 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 1,
1209 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 1
1210 },
1211 "codes": {
1212 "200": 1
1213 },
1214 "matches": 0,
1215 "customStats": {},
1216 "phases": [
1217 {
1218 "pause": 0.29122591362828076
1219 },
1220 {
1221 "duration": 1,
1222 "arrivalRate": 1
1223 }
1224 ]
1225 }
1226 ],
1227 "totals": {
1228 "scenariosCreated": 1,
1229 "scenariosCompleted": 0,
1230 "requestsCompleted": 1,
1231 "codes": {
1232 "200": 1
1233 },
1234 "errors": {
1235 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 1,
1236 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 1
1237 }
1238 },
1239 "errorMessage": "acceptance failure: scenarios run: 1, total errors: 2, error budget: 0"
1240}
1241
1242 Your function invocation has completed.
1243
1244{
1245 "errors": 2,
1246 "reports": [
1247 {
1248 "timestamp": "2019-04-17T21:56:59.527Z",
1249 "scenariosCreated": 1,
1250 "scenariosCompleted": 0,
1251 "requestsCompleted": 1,
1252 "latency": {
1253 "min": 24.7,
1254 "max": 24.7,
1255 "median": 24.7,
1256 "p95": 24.7,
1257 "p99": 24.7
1258 },
1259 "rps": {
1260 "count": 1,
1261 "mean": 2
1262 },
1263 "scenarioDuration": {
1264 "min": null,
1265 "max": null,
1266 "median": null,
1267 "p95": null,
1268 "p99": null
1269 },
1270 "scenarioCounts": {
1271 "0": 1
1272 },
1273 "errors": {
1274 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 1,
1275 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 1
1276 },
1277 "codes": {
1278 "200": 1
1279 },
1280 "matches": 0,
1281 "customStats": {},
1282 "phases": [
1283 {
1284 "pause": 0.29122591362828076
1285 },
1286 {
1287 "duration": 1,
1288 "arrivalRate": 1
1289 }
1290 ]
1291 }
1292 ],
1293 "totals": {
1294 "scenariosCreated": 1,
1295 "scenariosCompleted": 0,
1296 "requestsCompleted": 1,
1297 "codes": {
1298 "200": 1
1299 },
1300 "errors": {
1301 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 1,
1302 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 1
1303 }
1304 },
1305 "errorMessage": "acceptance failure: scenarios run: 1, total errors: 2, error budget: 0"
1306}
1307Results:
1308FAILED acceptance failure: scenarios run: 1, total errors: 2, error budget: 0
1309
1310```
1311
1312</p>
1313</details>
1314
1315You can observe the following in the result.
1316- Observe `"matches": 0,`. When any of the `match` statements fail it sets this to 0 (this could be confusing with scripts that don't have any `match` statements.
1317- Observe the following section where we list the number of scenarios created, scenarios completed, requests completed and list of errors. You can see it has information about the `match` statements that failed so you can use this information to find where in script failure occured.
1318```
1319 "totals": {
1320 "scenariosCreated": 1,
1321 "scenariosCompleted": 0,
1322 "requestsCompleted": 1,
1323 "codes": {
1324 "200": 1
1325 },
1326 "errors": {
1327 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 1,
1328 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 1
1329 }
1330```
1331- Observe the following error message regarding acceptance testing. Notice that error budget (default 0) can be modified as per your need. Read [here](#to-configure-acceptance-behavior) for more info.
1332```
1333"errorMessage": "acceptance failure: scenarios run: 1, total errors: 2, error budget: 0"
1334```
1335
1336Also, as this test failed, you will also observe that the process exit code is non-zero (number of `match` failures). On _Mac_ you can run command `echo $?` immediately after that to see the process exit code 2 in this case.
1337
1338### 7. Remove assets from AWS
1339This section is same as before. See [here](#8-remove-assets-from-aws) for details.
1340
1341## More about acceptance mode
1342### Acceptance testing in CI/CD
1343For the purposes of facilitating the use of this tool in a CI/CD pipeline, if any of the acceptance tests fail to successfully complete, the process will exit with a non-zero exit code.
1344
1345### Run `script.yml` exclusively in acceptance mode
1346To hard code acceptance mode into your script add the following in your `script.yml`:
1347```
1348mode: acceptance
1349...
1350```
1351*note: 'acceptance' may be abbreviated to 'acc' in the script*
1352
1353### Use same `script.yml` for performance and acceptance testing and monitoring
1354You can use the same `script.yml` for performance, acceptance testing and monitoring so you don't have to maintain multiple files. The scenarios that are important for performance test would be used for acceptance testing and monitoring as well.
1355
1356Since acceptance mode will run all scenarios only once (by default), the scripts that only are run in acceptance mode are not required to have a `phases` array in the `config` section of the script.
1357
1358### To configure acceptance behavior
1359You may configure [sampling](glossary.md#sampling) behavior. To control the number of samples taken, the time before taking a sample, or the number of errors constituting a failure, you may supply the following (default values listed):
1360
1361```
1362sampling:
1363 size: 1 # The size of sample set
1364 averagePause: 0.2 # The average number of seconds to pause between samples
1365 pauseVariance: 0.1 # The maximum difference of the actual pause from the average pause (in either direction)
1366 errorBudget: 0 # The number of observed errors to accept before alerting
1367```
1368
1369# Monitoring mode
1370Detect outages quickly. Use serverless-artillery to generate synthetic customer activity to continously validate the expected system behavior and optionally alert you immediately if your users will be impacted.
1371
1372Performance testing framework forms the basis of monitoring mode of serverless-artillery. Hence please go through [performance mode](#performance-mode-performanceload-testing) section before proceeding.
1373
1374## Tutorial 6: Monitoring mode without serverless-artillery alert
1375If you don't need serverless-artillery to send an alert when monitoring detects a problem then follow the tutorial here. You can [forward the test result to your data store](#providing-a-data-store-to-view-the-results-of-your-performance-test) and use alerting service there to noify you.
1376
1377### 1. Create custom deployment assets
1378Follow [Tutorial 3 to create custom deployment assets](#tutorial-3-performance-test-with-custom-deployment-assets).
1379
1380### 2. Setup AWS account credentials
1381This section is same as before. See [here](#before-running-serverless-artillery) for details.
1382
1383### 3. Tryout monitoring mode
1384#### 3.1. Deploy assets to AWS
1385This section is same as before. See [here](#3-deploy) for details. **Note** that monitoring is turned off by default in `serverless.yml` and hence the assets deployed in this step would not start monitoring.
1386
1387#### 3.2. Invoke monitoring once
1388When `-m` option is used in `slsart invoke` command, serverless-artillery invokes the load generator Lambda in monitoring mode. This is useful also during script development to avoid having to redeploy everytime you edit `script.yml` as mentioned [below](#5-deploy-assets-to-aws-to-start-monitoring).
1389```
1390slsart invoke -m --stage <your-unique-stage-name>
1391```
1392Given default [monitoring behavior configuration](#to-configure-monitoring-behavior), each scenario/flow in your script will be executed five times **only once**.
1393
1394### 4. Customize deployment assets to turn on monitoring
1395Open `serverless.yml` in your favorite editor. Under `functions` > `loadGenerator` > `events` > `schedule` > find `enabled: false`. Set it to `true`.
1396
1397Notice instruction 0 and 1 under `BEFORE ENABLING` section if they are applicable for your use case.
1398
1399### 5. Deploy assets to AWS to start monitoring
1400This section is same as before. See [here](#3-deploy) for details. **Note** that in the previous step monitoring was turned on and hence just _deploying_ the assets would turn on monitoring. Separate _invoke_ is not needed.
1401
1402**NOTE:** In performance test and acceptance test, the `script.yml` is passed with `invoke` command and hence redeployment is not needed when you edit `script.yml`. But monitoring mode uses the `script.yml` that is deployed in `slsart deploy` command. Also `invoke` command is not used in monitoring mode. Hence you need to redeploy everytime you edit `script.yml`. During script development you can take advantage of `slsart invoke -m` to [try monitoring](#3-tryout-monitoring-mode) with your script and avoid having to redeploy each time it is changed.
1403
1404Given default [moitoring behavior configuration](#to-configure-monitoring-behavior), each scenario/flow in your script will be executed five times **every minute**.
1405
1406### 6. Pause monitoring
1407Monitoring mode will run 24x7 until turned off or paused. If you need to pause monitoring you can do the following.
1408#### 6.1. Method 1: Using CloudWatch Rules
1409- Go to `AWS CloudWatch console` and find `Rules` (under `Events`) and search for the rule `${self:service}-${opt:stage, self:provider.stage}-monitoring` based on your `serverless.yml`.
1410- Do required [steps](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/Delete-or-Disable-Rule.html) to `Disable` this rule. This will prevent further invocation of the load generator Lambda function for monitoring.
1411 - To enable monitoring again `Enable` this rule.
1412- This will turn off monitoring and preserve the load generator Lambda logs.
1413#### 6.2. Method 2: Turn monitoring off in `serverless.yml`
1414- Open `serverless.yml` in your favorite editor.
1415- Under `functions` > `loadGenerator` > `events` > `schedule` > find `enabled: true`. Set it to `false`.
1416- Redeploy assets using same instructions as before. See [here](#3-deploy) for details.
1417
1418### 7. Remove assets from AWS
1419If you want to keep the 24x7 monitoring then you don't need to do this step.
1420
1421When you want to turn off monitoring then remove the assets from AWS. See [here](#8-remove-assets-from-aws) for details.
1422
1423## Tutorial 7: Monitoring mode with serverless-artillery alert
1424Here we will look into how to setup monitoring such that serverless-artillery sends alert when it detects a problem.
1425
1426### 1. Create custom deployment assets
1427Follow [Tutorial 3 to create custom deployment assets](#tutorial-3-performance-test-with-custom-deployment-assets).
1428
1429### 2. Setup AWS account credentials
1430This section is same as before. See [here](#before-running-serverless-artillery) for details.
1431
1432### 3. Customize script to have `match` clause
1433Ensure that you have `match` clauses defined for each request in your script's flows to validate the responses. See [here](#match-clause) to learn more about `match`.
1434
1435For the purpose of this tutorial you can copy paste the script from [here](#1-customize-scriptyml).
1436
1437### 4. Customize deployment assets to add at least one subscription
1438Open `serverless.yml` in your favorite editor.
1439- _Uncomment_ the line of `Subscription` section.
1440```
1441# Subscription: # docs at https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-subscription.html
1442```
1443- Add at least one subscription. In this tutorial we will use email subscription.
1444 - _Uncomment_ following two lines.
1445```
1446# - Endpoint: <target>@<host> # the endpoint is an email address
1447# Protocol: email
1448```
1449 - Replace `<target>@<host>` with your email address. Example, `mymail@myhost.com`.
1450
1451### 5. Tryout monitoring mode
1452#### 5.1. Deploy assets to AWS
1453This section is same as before. See [here](#31-deploy-assets-to-aws) for details.
1454
1455#### 5.2. Invoke monitoring once
1456This section is same as before. See [here](#32-invoke-monitoring-once) for details.
1457
1458### 6. Test failure scenario
1459We will inject failure scenario so that the `match` fails and monitoring mode sends us an alert.
1460
1461#### 6.1. Edit `script.yml` to fail `match`
1462Edit `script.yml` as mentioned [here](#61-edit-scriptyml-to-fail-match) to cause `match` to fail.
1463
1464#### 6.2. Invoke monitoring once
1465Follow instruction [here](#32-invoke-monitoring-once) to use `-m` option of `slsart invoke` command to invoke monitoring once to try our modified `script.yml` without having to redeploy assets.
1466
1467Given default [moitoring behavior configuration](#to-configure-monitoring-behavior), each scenario/flow in your script will be executed five times **only once**. If all five of them fail (we try to avoid notifying you about blips) then you should receive a notification via the configured mechanism (email in the case of this tutorial).
1468
1469Below is sample email.
1470<details><summary>Click to expand/collapse</summary>
1471<p>
1472
1473```
1474Alert:
1475 monitoring failure: scenarios run: 5, total errors: 10, error budget: 4
1476
1477Logs:
1478Full analysis:
1479{
1480 "errors": 10,
1481 "reports": [
1482 {
1483 "timestamp": "2019-04-17T23:16:17.050Z",
1484 "scenariosCreated": 5,
1485 "scenariosCompleted": 0,
1486 "requestsCompleted": 5,
1487 "latency": {
1488 "min": 12.4,
1489 "max": 25.2,
1490 "median": 24,
1491 "p95": 25.2,
1492 "p99": 25.2
1493 },
1494 "rps": {
1495 "count": 5,
1496 "mean": 0.93
1497 },
1498 "scenarioDuration": {
1499 "min": null,
1500 "max": null,
1501 "median": null,
1502 "p95": null,
1503 "p99": null
1504 },
1505 "scenarioCounts": {
1506 "0": 5
1507 },
1508 "errors": {
1509 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 5,
1510 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 5
1511 },
1512 "codes": {
1513 "200": 5
1514 },
1515 "matches": 0,
1516 "customStats": {},
1517 "phases": [
1518 {
1519 "pause": 0.2255259122021872
1520 },
1521 {
1522 "duration": 1,
1523 "arrivalRate": 1
1524 },
1525 {
1526 "pause": 0.2968933399583734
1527 },
1528 {
1529 "duration": 1,
1530 "arrivalRate": 1
1531 },
1532 {
1533 "pause": 0.16654656047499483
1534 },
1535 {
1536 "duration": 1,
1537 "arrivalRate": 1
1538 },
1539 {
1540 "pause": 0.19488041671127268
1541 },
1542 {
1543 "duration": 1,
1544 "arrivalRate": 1
1545 },
1546 {
1547 "pause": 0.19656039636288947
1548 },
1549 {
1550 "duration": 1,
1551 "arrivalRate": 1
1552 }
1553 ]
1554 }
1555 ],
1556 "totals": {
1557 "scenariosCreated": 5,
1558 "scenariosCompleted": 0,
1559 "requestsCompleted": 5,
1560 "codes": {
1561 "200": 5
1562 },
1563 "errors": {
1564 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 5,
1565 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 5
1566 }
1567 },
1568 "errorMessage": "monitoring failure: scenarios run: 5, total errors: 10, error budget: 4"
1569}
1570
1571
1572--
1573If you wish to stop receiving notifications from this topic, please click or visit the link below to unsubscribe:
1574https://sns.us-east-1.amazonaws.com/unsubscribe.html?SubscriptionArn=arn:aws:sns:us-east-1:515126931066:serverless-artillery-hPDAiDvuzL-ash-monitoringAlerts-3PPB71S63RM2:e11606d1-e70d-482c-82f9-eff26a760e68&Endpoint=ashmi.s.bhanushali@nordstrom.com
1575
1576Please do not reply directly to this email. If you have any questions or comments regarding this email, please contact us at https://aws.amazon.com/support
1577```
1578
1579</p>
1580</details>
1581
1582You will also see the following output at the command line.
1583<details><summary>Click to expand/collapse</summary>
1584<p>
1585
1586```
1587
1588 Invoking test Lambda
1589
1590{
1591 "errors": 10,
1592 "reports": [
1593 {
1594 "timestamp": "2019-04-17T23:06:29.570Z",
1595 "scenariosCreated": 5,
1596 "scenariosCompleted": 0,
1597 "requestsCompleted": 5,
1598 "latency": {
1599 "min": 21.4,
1600 "max": 52.1,
1601 "median": 25.8,
1602 "p95": 52.1,
1603 "p99": 52.1
1604 },
1605 "rps": {
1606 "count": 5,
1607 "mean": 0.94
1608 },
1609 "scenarioDuration": {
1610 "min": null,
1611 "max": null,
1612 "median": null,
1613 "p95": null,
1614 "p99": null
1615 },
1616 "scenarioCounts": {
1617 "0": 5
1618 },
1619 "errors": {
1620 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 5,
1621 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 5
1622 },
1623 "codes": {
1624 "200": 5
1625 },
1626 "matches": 0,
1627 "customStats": {},
1628 "phases": [
1629 {
1630 "pause": 0.19110438826323195
1631 },
1632 {
1633 "duration": 1,
1634 "arrivalRate": 1
1635 },
1636 {
1637 "pause": 0.2695130316914205
1638 },
1639 {
1640 "duration": 1,
1641 "arrivalRate": 1
1642 },
1643 {
1644 "pause": 0.10236624757585773
1645 },
1646 {
1647 "duration": 1,
1648 "arrivalRate": 1
1649 },
1650 {
1651 "pause": 0.13588464289194607
1652 },
1653 {
1654 "duration": 1,
1655 "arrivalRate": 1
1656 },
1657 {
1658 "pause": 0.2951659631896233
1659 },
1660 {
1661 "duration": 1,
1662 "arrivalRate": 1
1663 }
1664 ]
1665 }
1666 ],
1667 "totals": {
1668 "scenariosCreated": 5,
1669 "scenariosCompleted": 0,
1670 "requestsCompleted": 5,
1671 "codes": {
1672 "200": 5
1673 },
1674 "errors": {
1675 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 5,
1676 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 5
1677 }
1678 },
1679 "errorMessage": "monitoring failure: scenarios run: 5, total errors: 10, error budget: 4"
1680}
1681
1682 Your function invocation has completed.
1683
1684{
1685 "errors": 10,
1686 "reports": [
1687 {
1688 "timestamp": "2019-04-17T23:06:29.570Z",
1689 "scenariosCreated": 5,
1690 "scenariosCompleted": 0,
1691 "requestsCompleted": 5,
1692 "latency": {
1693 "min": 21.4,
1694 "max": 52.1,
1695 "median": 25.8,
1696 "p95": 52.1,
1697 "p99": 52.1
1698 },
1699 "rps": {
1700 "count": 5,
1701 "mean": 0.94
1702 },
1703 "scenarioDuration": {
1704 "min": null,
1705 "max": null,
1706 "median": null,
1707 "p95": null,
1708 "p99": null
1709 },
1710 "scenarioCounts": {
1711 "0": 5
1712 },
1713 "errors": {
1714 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 5,
1715 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 5
1716 },
1717 "codes": {
1718 "200": 5
1719 },
1720 "matches": 0,
1721 "customStats": {},
1722 "phases": [
1723 {
1724 "pause": 0.19110438826323195
1725 },
1726 {
1727 "duration": 1,
1728 "arrivalRate": 1
1729 },
1730 {
1731 "pause": 0.2695130316914205
1732 },
1733 {
1734 "duration": 1,
1735 "arrivalRate": 1
1736 },
1737 {
1738 "pause": 0.10236624757585773
1739 },
1740 {
1741 "duration": 1,
1742 "arrivalRate": 1
1743 },
1744 {
1745 "pause": 0.13588464289194607
1746 },
1747 {
1748 "duration": 1,
1749 "arrivalRate": 1
1750 },
1751 {
1752 "pause": 0.2951659631896233
1753 },
1754 {
1755 "duration": 1,
1756 "arrivalRate": 1
1757 }
1758 ]
1759 }
1760 ],
1761 "totals": {
1762 "scenariosCreated": 5,
1763 "scenariosCompleted": 0,
1764 "requestsCompleted": 5,
1765 "codes": {
1766 "200": 5
1767 },
1768 "errors": {
1769 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 5,
1770 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 5
1771 }
1772 },
1773 "errorMessage": "monitoring failure: scenarios run: 5, total errors: 10, error budget: 4"
1774}
1775Results:
1776FAILED monitoring failure: scenarios run: 5, total errors: 10, error budget: 4
1777
1778```
1779
1780</p>
1781</details>
1782
1783You can observe the following in the result.
1784- Observe `"matches": 0,`. When any of the `match` statements fail it sets this to 0 (this could be confusing with scripts that don't have any `match` statements).
1785- Observe the following section where we list the number of scenarios created, scenarios completed, requests completed and list of errors. You can see it has information about the `match` statements that failed so you can use this information to find where in script failure occured.
1786```
1787 "totals": {
1788 "scenariosCreated": 5,
1789 "scenariosCompleted": 0,
1790 "requestsCompleted": 5,
1791 "codes": {
1792 "200": 5
1793 },
1794 "errors": {
1795 "Failed match: expected=failvalue got=postman-echo.com expression=$.headers.host": 5,
1796 "Failed match: expected=failvalue got=https expression=$.headers.x-forwarded-proto": 5
1797 }
1798 },
1799```
1800- Observe the following error message regarding acceptance testing. Notice that error budget (default 4) can be modified as per your need. Read [here](#to-configure-monitoring-behavior) for more info.
1801```
1802"errorMessage": "monitoring failure: scenarios run: 5, total errors: 10, error budget: 4"
1803```
1804
1805Also, as this test failed, you will also observe that the process exit code is non-zero (number of `match` failures). On _Mac_ you can run command `echo $?` immediately after that to see the process exit code 10 in this case.
1806
1807### 7. Customize deployment assets to turn on monitoring
1808This section is same as before. See [here](#4-customize-deployment-assets-to-turn-on-monitoring) for details.
1809
1810### 8. Deploy assets to AWS to start monitoring
1811This section is same as before. See [here](#5-deploy-assets-to-aws-to-start-monitoring) for details.
1812
1813In this step, along with deployment asset we are also deploying the modified `script.yml` where `match` will fail. Hence once the assets are deployed, monitoring mode will turn on and send you an email to alert about these failures.
1814
1815Given default [monitoring behavior configuration](#to-configure-monitoring-behavior), each scenario/flow in your script will be executed five times **every minute**. All five of the executions will cause the `match` statements to fail exceeding `errorBudget` (default 4) and hence would send the email alerting about the problem (once every minute).
1816
1817### 9. Pause monitoring
1818This section is same as before. See [here](#6-pause-monitoring) for details.
1819
1820### 10. Remove assets from AWS
1821This section is same as before. See [here](#8-remove-assets-from-aws) for details.
1822
1823## More about monitoring mode
1824### Run `script.yml` exclusively in monitoring mode
1825To hard code monitoring mode into your script add the following in your `script.yml`:
1826```
1827mode: monitoring
1828...
1829```
1830*note: 'monitoring' may be abbreviated to 'mon' in the script*
1831
1832### Use same `script.yml` for performance and acceptance testing and monitoring
1833You can use the same `script.yml` for performance, acceptance testing and monitoring so you don't have to maintain multiple files. The scenarios that are important for performance test would be used for acceptance testing and monitoring as well.
1834
1835Since monitoring mode will run all scenarios five times (by default), the scripts that only are run in monitoring mode are not required to have a `phases` array in the `config` section of the script.
1836
1837### To configure monitoring behavior
1838You may configure [sampling](glossary.md#sampling) behavior. To control the number of samples taken, the time before taking a sample, or the number of errors constituting a failure, you may supply the following (default values listed):
1839
1840```
1841sampling:
1842 size: 5 # The size of sample set
1843 averagePause: 0.2 # The average number of seconds to pause between samples
1844 pauseVariance: 0.1 # The maximum difference of the actual pause from the average pause (in either direction)
1845 errorBudget: 4 # The number of observed errors to accept before alerting
1846```
1847
1848# Detailed Usage
1849```
1850$ slsart --help
1851
1852slsart <command>
1853
1854Commands:
1855 slsart deploy Deploy a default version of the function that will execute
1856 your Artillery scripts. See
1857 https://serverless.com/framework/docs/providers/aws/cli-refe
1858 rence/deploy/ for reference.
1859 slsart invoke Invoke your function with your Artillery script. Will
1860 prefer a script given by `-d`, `--data`, `-p`, or `--path`
1861 over a `script.[yml|json]` file in the current directory
1862 over the default script. Invocation mode will default to
1863 "performance" but adding the `-a` flag will run the script
1864 in "acceptance" mode. See
1865 https://serverless.com/framework/docs/providers/aws/cli-refe
1866 rence/invoke/ for reference.
1867 slsart kill Stop a currently running load test and remove the function.
1868 slsart remove Remove the function and the associated resources created for
1869 or by it. See
1870 https://serverless.com/framework/docs/providers/aws/cli-refe
1871 rence/remove/ for reference.
1872 slsart script Create a local Artillery script so that you can customize it
1873 for your specific load requirements. See
1874 https://artillery.io for documentation.
1875 slsart configure Create a local copy of the deployment assets for
1876 modification and deployment. See
1877 https://serverless.com/framework/docs/ for documentation.
1878
1879Options:
1880 --help Show help [boolean]
1881 --version Show version number [boolean]
1882 -D, --debug Execute the command in debug mode. It will be chatty about
1883 what it is happening in the code.
1884 -V, --verbose Execute the command in verbose mode. It will be chatty about
1885 what it is attempting to accomplish.
1886```
1887
1888## Commands
1889### `deploy`
1890```
1891slsart deploy --help
1892```
1893```
1894slsart deploy
1895
1896Deploy a default version of the function that will execute your Artillery
1897scripts. See
1898https://serverless.com/framework/docs/providers/aws/cli-reference/deploy/ for
1899reference.
1900
1901Options:
1902 --help Show help [boolean]
1903 --version Show version number [boolean]
1904 -D, --debug Execute the command in debug mode. It will be chatty about
1905 what it is happening in the code.
1906 -V, --verbose Execute the command in verbose mode. It will be chatty about
1907 what it is attempting to accomplish.
1908```
1909
1910### `invoke`
1911```
1912slsart invoke --help
1913```
1914```
1915slsart invoke
1916
1917Invoke your function with your Artillery script. Will prefer a script given by
1918`-d`, `--data`, `-p`, or `--path` over a `script.[yml|json]` file in the current
1919directory over the default script. Invocation mode will default to
1920"performance" but adding the `-a` flag will run the script in "acceptance" mode.
1921See https://serverless.com/framework/docs/providers/aws/cli-reference/invoke/
1922for reference.
1923
1924Options:
1925 --help Show help [boolean]
1926 --version Show version number [boolean]
1927 -D, --debug Execute the command in debug mode. It will be chatty about
1928 what it is happening in the code.
1929 -V, --verbose Execute the command in verbose mode. It will be chatty
1930 about what it is attempting to accomplish.
1931 -a, --acceptance Execute the script in acceptance mode. It will execute each
1932 flow once, reporting failures.
1933 -m, --monitoring Execute the script in monitoring mode. It will execute each
1934 flow a multiple of times, alerting if the number of errors
1935 exceeds the configured threshold.
1936 -d, --data A stringified script to execute
1937 -p, --path A path to the file containing the script to execute
1938 --si, --stdIn Have serverless read the event to invoke the remote function
1939 with from the "standard in" stream
1940 --jo, --jsonOnly Only write JSON to console.log to facilitate piping the
1941 invocation result into a tool such as jq
1942```
1943
1944### `kill`
1945```
1946slsart kill --help
1947```
1948```
1949slsart kill
1950
1951Stop a currently running load test and remove the function.
1952
1953Options:
1954 --help Show help [boolean]
1955 --version Show version number [boolean]
1956 -D, --debug Execute the command in debug mode. It will be chatty about
1957 what it is happening in the code.
1958 -V, --verbose Execute the command in verbose mode. It will be chatty about
1959 what it is attempting to accomplish.
1960```
1961
1962### `remove`
1963```
1964slsart remove --help
1965```
1966```
1967slsart remove
1968
1969Remove the function and the associated resources created for or by it. See
1970https://serverless.com/framework/docs/providers/aws/cli-reference/remove/ for
1971reference.
1972
1973Options:
1974 --help Show help [boolean]
1975 --version Show version number [boolean]
1976 -D, --debug Execute the command in debug mode. It will be chatty about
1977 what it is happening in the code.
1978 -V, --verbose Execute the command in verbose mode. It will be chatty about
1979 what it is attempting to accomplish.
1980```
1981
1982### `script`
1983```
1984slsart script --help
1985```
1986```
1987slsart script
1988
1989Create a local Artillery script so that you can customize it for your specific
1990load requirements. See https://artillery.io for documentation.
1991
1992Options:
1993 --help Show help [boolean]
1994 --version Show version number [boolean]
1995 -D, --debug Execute the command in debug mode. It will be chatty about
1996 what it is happening in the code.
1997 -V, --verbose Execute the command in verbose mode. It will be chatty about
1998 what it is attempting to accomplish.
1999 -e, --endpoint The endpoint to load with traffic. [string]
2000 -d, --duration The duration, in seconds, to load the given endpoint. [number]
2001 -r, --rate The rate, in requests per second, at which to load the given
2002 endpoint. [number]
2003 -t, --rampTo The rate to ramp up to from the given (starting) rate, in
2004 requests per second at which to load the given endpoint.
2005 [number]
2006 -o, --out The file to output the generated script in to. [string]
2007```
2008
2009### `configure`
2010```
2011slsart configure --help
2012```
2013```
2014slsart configure
2015
2016Create a local copy of the deployment assets for modification and deployment.
2017See https://docs.serverless.com for documentation.
2018
2019Options:
2020 --help Show help [boolean]
2021 --version Show version number [boolean]
2022 -D, --debug Execute the command in debug mode. It will be chatty about
2023 what it is happening in the code.
2024 -V, --verbose Execute the command in verbose mode. It will be chatty about
2025 what it is attempting to accomplish.
2026```
2027
2028# Troubleshooting
2029### Problems installing?
2030#### Error: npm ERR! code EACCES
2031If you are installing into a node_modules owned by root and getting error `npm ERR! code EACCES`, [read this](root-owns-node-modules.md).
2032
2033# External References
20341. [artillery.io](https://artillery.io) for documentation about how to define your load shape, volume, targets, inputs, et cetera
20352. [serverless.com](https://serverless.com/framework/docs/) for documentation about how to create a custom function configuration
20363. [serverless-artillery](https://github.com/Nordstrom/serverless-artillery) README for documentation on the use of this tool
20374. [serverless-star](https://github.com/Nordstrom/serverless-star) Next generation implementation and generalization of the arbitrarily wide work distribution capability
2038
2039# If you've read this far
2040Please let us know any feedback on this tool. We would love to hear from you. Thank you!