Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SNS Load Testing Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Amazon.SimpleNotificationService;
using Newtonsoft.Json;
namespace sns_load_test
class Program
//Change this to control what SNS topic you are publishing to
const string TopicArn = "arn:aws:sns:ap-southeast-2:xxxxxxxxxxxxxxxxxxxx";
//Change this to control how many messages to send in the load test
const int NumberOfMessagesToSend = 100;
static void Main(string[] args)
static async Task Run()
List<string> serializedMessages = new List<string>();
for (int i = 0; i < NumberOfMessagesToSend; i++)
//Customise the content of your SNS messages as need be here
var message = new {
Property = "Hello World!"
var snsClient = new AmazonSimpleNotificationServiceClient(Amazon.RegionEndpoint.APSoutheast2);
IEnumerable<Task> tasks = serializedMessages.Select(async serializedMessage =>
await snsClient.PublishAsync(TopicArn, serializedMessage);
catch (Exception ex)
await Task.WhenAll(tasks);
<Project Sdk="Microsoft.NET.Sdk">
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment