Skip to content

dev4any1/awsQbench

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

AWS SNS/SQS Load Test

A Java-based load testing framework for AWS SNS & SQS that measures publishing and receiving throughput across Standard and FIFO topics/queues.

This repository contains the test runner, client helpers, and configuration for benchmarking SNS publishing, SNS→SQS delivery, and direct SQS send/receive performance using AWS SDK v2 (async).


📂 Project Structure

aws-sns-sqs-test/
 ├── src/main/java/net/dev4any1/messaging/awsSnsSqsTest/
 │    ├── Main.java            # Entry point
 │    ├── AWSTest.java         # Core load testing framework
 │    ├── AwsClients.java      # SNS/SQS clients and helpers
 │
 ├── src/main/resources/
 │    ├── app.properties       # Test configuration (region, queue/topic ARNs)
 │    ├── log4j2.xml           # Logging configuration
 │    ├── template.xml         # Sample test message
 │
 ├── pom.xml                   # Maven build file
 └── README.md

⚙️ Requirements

  • Java 8+
  • Maven 3.6+
  • AWS account with SNS and SQS enabled
  • Please set AWS_LOCAL_PROFILE in app.properties according to the valid profile name in ~/.aws/credentials or disable this property if you are running inside AWS.

🏗️ Build

mvn clean package

This creates a runnable fat JAR in:

target/aws-sns-sqs-test.jar

▶️ Run

Run all configured tests

java -jar target/aws-sns-sqs-test.jar

Run a specific test

java -jar target/aws-sns-sqs-test.jar 0

Run a range of tests

java -jar target/aws-sns-sqs-test.jar 0 3

The runner reads app.properties to discover tests defined as SQS_QUEUE_URL_N / SNS_TOPIC_ARN_N / TEST_NAME_N.


🔧 Configuration

Edit src/main/resources/app.properties to define AWS region, profile, queues, and topics.

Example snippet:

AWS_DOMAIN=amazonaws.com
AWS_LOCAL_PROFILE=MY_AWESOME_PROFILE
AWS_REGION=ap-southeast-1

LOADTEST_MESSAGES_COUNT=10000

TEST_NAME_0=SQS standard; SNS standard
SQS_QUEUE_URL_0=https://sqs.ap-southeast-1.amazonaws.com/123456789012/MY_STD_QUEUE
SNS_TOPIC_ARN_0=arn:aws:sns:ap-southeast-1:123456789012:MY_STD_TOPIC

Key properties used by the runner (defaults live in src/main/resources/app.properties):

  • AWS_REGION — AWS region
  • AWS_LOCAL_PROFILE — (optional) local AWS profile for credentials
  • AWS_LONG_POLLING_TIMEOUT_SECONDS — receive wait time
  • AWS_VISIBILITY_TIMEOUT_SECONDS — receive visibility timeout
  • AWS_MAXBATCH — max number of messages per receive (<= 10)
  • LOADTEST_MESSAGES_COUNT — number of messages to send/receive per test

📊 Test Results

Below are the exact measured results from a full run (run on 2025-10-03) with 10,000 messages per test in ap-southeast-1.

The run was executed on an r5b.2xlarge instance. CPU details from the instance during testing:

CPU(s):              8
Thread(s) per core:  2
Core(s) per socket:  4
Socket(s):           1
Model name:          Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
CPU MHz:             3095.041

Log source: the numbers below were extracted from the test runner logs produced during the run (timestamps in the logs are from 2025-10-03).

Test name SNS publish th. msg/sec SQS-SNS receive th. msg/sec SQS send th. msg/sec SQS receive th. msg/sec
SQS standard; SNS standard 60.036 625.000 147.393 714.286
SQS standard; SNS fifo 56.828 625.000 154.433 714.286
SQS fifo; SNS fifo 57.581 303.030 110.763 312.500
SQS fifo dedup; SNS fifo 61.890 312.500 105.594 312.500
SQS fifo fast; SNS fifo 59.741 303.030 104.432 312.500
SQS fifo fast dedup; SNS fifo 59.879 312.500 106.002 312.500

Where these numbers came from (example log lines):

  • 2025-10-03 13:14:07.1 ... SNS publishing throughput: [60.036] messages/second; sends 10000 messages in 166.566 seconds
  • 2025-10-03 13:14:23.8 ... SNS receiving throughput: [625.000] messages/second; receives 10000 messages in 16.000 seconds
  • 2025-10-03 13:15:31.8 ... SQS sending throughput: [147.393] messages/second; sends 10000 messages in 67.846 seconds
  • 2025-10-03 13:15:46.4 ... SQS receiving throughput: [714.286] messages/second; receives 10000 messages in 14.000 seconds

(Full run logs include similar lines for each of the six test cases.)


📜 How It Works (quick)

The framework performs the following per test case:

  1. (If SNS topic is configured) Connect the SQS queue to the SNS topic by updating the queue policy and creating a subscription.
  2. Publish LOADTEST_MESSAGES_COUNT messages to the SNS topic (or directly to SQS for direct-send tests).
  3. Receive messages from the SQS queue using asynchronous receives with long polling and delete them.
  4. Measure the time taken and calculate throughput (messages/second) for each operation:
    • SNS publish throughput (time to publish N messages to SNS)
    • SQS-SNS receive throughput (time to receive N messages that SNS delivered to the queue)
    • SQS send throughput (time to SendMessage N messages directly to the queue)
    • SQS receive throughput (time to receive N messages directly from the queue)

The code uses shared async clients (SnsAsyncClient, SqsAsyncClient) and recursive CompletableFuture chains to saturate the service while maintaining a simple control flow.


🧭 Tips & Observations

  • Standard queues show the highest end-to-end throughput. They are good for high-volume messaging where ordering across all messages is not required.
  • FIFO queues consistently show lower throughput (ordering + deduplication overhead). Performance varies across FIFO configurations — e.g. dedup toggles will affect throughput.
  • In this run SNS publish throughput is the bottleneck compared to direct SQS send in several test cases.
  • Always run multiple iterations and average results for production-grade benchmarking — single runs can be influenced by transient network or region-level factors.

🔁 Reproducing the Run

  1. Configure app.properties with your topic ARNs and queue URLs. Use distinct queues/topics for each test case.
  2. Ensure the SQS queue policy allows SNS to sqs:SendMessage from the topic ARN (the code can set this via DeliverySetup).
  3. Build & run the jar as shown in the Run section.
  4. Inspect logs (configured via log4j2.xml) for the * throughput: lines and collect numbers.

📎 Diagram

A simple flow diagram (Publisher → SNS → SQS → Consumers) is useful for docs. Place a PNG (e.g. docs/sns-sqs-flow.png) next to this README if desired.


🔐 License

MIT License


About

A Java-based load testing framework for AWS SNS & SQS that measures publishing and receiving throughput across Standard and FIFO topics/queues

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages