Send batch messages to AWS SQS

What is Amazon Simple Queue Service

Amazon Simple Queue Service (Amazon SQS) offers a secure, durable, and available hosted queue that lets you integrate and decouple distributed software systems and components.

There is two type of Queue available in AWS.

  • Standard Queue
  • FIFO Queue

You can trigger lambda from SQS. Or you may want to implement a service broker using aws SQS.

However, you may found yourself in a situation where you need to send millions of messages to your queue because you want to check performance or stress of your lambda or application. It is better to perform the stress test before you go to the high traffic production system

I was asked to perform a stress test some lambdas those triggered by standard queues. So, I disabled the triggers on lambdas and sent thousands of messages to the queues. After that enabled the triggers to get performance metrics. To send predefined messages I create a small app in dotnet core. To know more about configuring AWS SQS messages to trigger a Lambda function you can read my blog

AWS Toolkit

There is a visual studio extension available, AWS Toolkit for Visual Studio 2017 for AWS SDK for .net You may find the developer guide here. To de

Creating a Queue

You can create a new SQS from Amazon SQS console or using aws cloudformation or using SDK. A tutorial is available on SQSDeveloperGuide

Sending Messages

You may send a single message to the queue. You can also send batch messages to aws sqs.

Why batch is preferable

Increasing Throughput sending messages batch action. To reduce costs or manipulate up to 10 messages with a single action.

Find more about this on Action Batching and tutorial here

 

Console app to send batch messages

Please note, the aws console does not support batch actions.

I have created a console app so that will help to send single or millions of messages to a specific queue. All the messages are sending in batch.

  • Batch size has been defined in the code.
  • Queue name and number of messages can be changed from appsettings.json
  • You can also pass the number of messages as arguments

You can download the code from Github

The following command will send 1 batch of 10 messages

dotnet run 10 y

Here, you can find some basic action you can perform some actions with your SQS via aws .net sdk

I would like to hear your thoughts