This is a basic starting point for conducting performance testing on AWS.
This is a basic starting point for conducting performance testing on AWS, for the compute services EC2, Fargate, and Lambda. The provided application is a small "Hello world" application written in Node (running on Fastify).
Tests are conducted using k6. They come configured for 500 virtual users, hitting an endpoint for 30 seconds. The test also checks to ensure that >99% of all hits are successes and that the p95 duration is under 200ms.
For the Lambda solution, there is full deployment automation in place using Serverless Framework. For EC2 and Fargate, there are steps and scripts provided for provisioning the infrastructure and building and pushing the container image that will be used.
Clone, fork, or download the repo as you normally would. Run npm install
.
Make sure to check these files out and change them if their use applies to your use case.
scripts/push.sh
scripts/ssh.sh
serverless.yml
Once you have deployed some testing application(s), update the endpoints in scripts/test.js
.
npm run setup
: Install k6 and Podman (assumes Mac)npm test
: Run the k6 load testnpm start
: Run the Lambda application locallynpm start:server
: Run the containerized application locallynpm run build
: Package Lambda stack with Serverless Frameworknpm run build:image
: Use Podman to build the imagenpm run push
: Use Podman to build and push image to AWS ECRnpm run deploy
: Deploy Lambda stack to AWS with Serverless Frameworknpm run teardown
: Remove Lambda stack from AWSThere is no automation provided beyond the scripts. Instead, follow the web console wizard and the below general steps.
Note that the described setup is not strictly equal to, for example, the Lambda setup unless you add (for example) HTTPS.
Basic instructions:
t4g.micro
(or other configuration)scripts/ssh.sh
- run that scriptscripts/ec2-setup.sh
, it should end with the server being in a running statecurl ec2-{RANDOM}.{REGION}.compute.amazonaws.com:8080
There is no automation provided beyond the scripts. Instead, follow the web console wizard and the below general steps.
You may want to follow this guide if you want a guided tour of the overall steps.
Note that the described setup is not strictly equal to, for example, the Lambda setup unless you add (for example) HTTPS.
Basic instructions:
Simply run npm run deploy
(after having installed dependencies and being logged in through the CLI environment).
You'll get an endpoint you can use.
There are some configuration options in the serverless.yml
if you want to set it up in other ways than the provided one.