Hello everyone βπ»,
Recently I needed a load tester tool that simply sends requests to my Rest API. I created a simple project. Here is what I have come up with!
You can reach the https://github.com/ahmettkartal/serverless-api-load-tester/ repo from here.
Before You Begin
Make sure you have:
- AWS Account
- Node.js installed
- Serverless Framework installed
- AWS SQS queue created with default settings
Don't worry if you're new to configuring the Serverless Framework or setting up AWS credentials. You can follow this documentation. Also, you can follow up on how to setup AWS credentials from this documentation
Configuring the SQS Queue
- This project sends requests using AWS SQS. You can create a simple FIFO queue with default settings.
Once your queue is created, you'll need to update the queue ARN and URL in the
config.development.json
file under theconfig
folder. Alternatively, you can set these variables in therun.sh
file for local development.Replace
YOUR_SQS_QUEUE_ARN_HERE
andYOUR_SQS_QUEUE_URL_HERE
, with your actual queue information.
Deploying the Project
- Deploy the project to AWS using the Serverless Framework with this command:
serverless deploy --stage development
- If you want to create a new stage, you have to create the stage's config file under the
config
folder with the stage's name. For example, for a stage calledproduction
, create a file namedconfig.production.json
.
Running the Project
After the deployment process, you'll get an endpoint like
https://endpoint_key.execute-api.eu-central-1.amazonaws.com/development
. This URL serves as your base endpoint.To add a request to the queue you can use the
{{url}}/load-tests
endpoint. Below, you'll find an example of sample data you can use:
{
"iteration" : 100,
"request_data" : {
"method" : "post",
"url" :"YOUR_LOAD_TEST_ENDPOINT",
"data" : {
"key" :"value"
},
"headers" : {
"Content-Type": "application/json"
}
}
}
I used webhook.site for testing. It is a great tool.
Also you can find the Postman collection at the repo
The iteration
parameter denotes the number of requests, and the request_data
configures Axios.
That is it! Now you have your load tester tool π₯³. If you have additional ideas or any problems, please write me βπ».
Top comments (0)