Skip to content

Scaling and event processing with SNS and SQS

-1

A solutions architect is designing a solution to process events. The solution must have the ability to scale in and out based on the number of events that the solution receives. If a processing error occurs, the event must move into a separate queue for review.

Which solution will meet these requirements?

A. Send event details to an Amazon Simple Notification Service (Amazon SNS) topic. Configure an AWS Lambda function as a subscriber to the SNS topic to process the events. Add an on-failure destination to the function. Set an Amazon Simple Queue Service (Amazon SQS) queue as the target.

B. Publish events to an Amazon Simple Queue Service (Amazon SQS) queue. Create an Amazon EC2 Auto Scaling group. Configure the Auto Scaling group to scale in and out based on the ApproximateAgeOfOldestMessage metric of the queue. Configure the application to write failed messages to a dead-letter queue.

C. Write events to an Amazon DynamoDB table. Configure a DynamoDB stream for the table. Configure the stream to invoke an AWS Lambda function. Configure the Lambda function to process the events.

D. Publish events to an Amazon EventBndge event bus. Create and run an application on an Amazon EC2 instance with an Auto Scaling group that is behind an Application Load Balancer (ALB). Set the ALB as the event bus target. Configure the event bus to retry events. Write messages to a dead-letter queue if the application cannot process the messages.

2 Answers
0

Hello.

I thought option B was the correct answer.
I made the decision based on the fact that the problem statement mentions scale in and scale out, and that it scales based on the number of events.
The metric "ApproximateAgeOfOldestMessage" shows the age of the oldest message in SQS.
The larger the value of this metric, the more messages are not being processed and are continuing to accumulate in the queue.
Therefore, I thought it would be possible to process messages efficiently by controlling scale-out and scale-in using this metric.
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-available-cloudwatch-metrics.html

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

0

The correct answer is:

A. Send event details to an Amazon Simple Notification Service (Amazon SNS) topic. Configure an AWS Lambda function as a subscriber to the SNS topic to process the events. Add an on-failure destination to the function. Set an Amazon Simple Queue Service (Amazon SQS) queue as the target.


Let's break down the requirements and evaluate each option:

Requirements:

  1. Scale in and out based on the number of events → Needs automatic, event-driven scaling.
  2. If a processing error occurs, the event must move into a separate queue for review → Needs error handling with failed events sent to a "review" queue (i.e., a dead-letter or failure queue).

Option A – Correct ✅

  • SNS → Lambda: SNS can fan out messages to subscribers like Lambda.
  • Lambda scales automatically in response to incoming events — this satisfies the scale in/out requirement.
  • On-failure destinations: AWS Lambda supports on-failure destinations. You can configure a dead-letter queue (DLQ) using Amazon SQS to capture failed invocations.
  • This means if the Lambda function fails to process an event, the event payload is sent to the SQS queue for review — satisfies the error handling requirement.

✅ Meets both key requirements.


Option B – ❌

  • Uses SQS + EC2 Auto Scaling.
  • EC2 Auto Scaling can scale based on ApproximateAgeOfOldestMessage, which is valid for scaling.
  • Can configure a dead-letter queue (DLQ) for failed messages — good for error handling.
  • BUT: EC2 instances are not as responsive or granular as Lambda. They take time to launch, and scaling may lag.
  • Also, the requirement is for a solution that scales based on the number of events — Lambda is event-per-execution, while EC2 scales coarsely (per instance).
  • While this can work, it's not optimal and not as scalable or serverless as needed.

❌ Not the best fit — less efficient and more operational overhead.


Option C – ❌

  • DynamoDB Streams + Lambda:
    • Lambda scales automatically — ✅
    • But: DynamoDB Streams are not intended as a general event ingestion system unless the events are coming from DynamoDB updates.
  • The scenario says "process events" — implies external events being ingested.
  • This solution assumes events are written to a DynamoDB table, which may not be appropriate or efficient.
  • Also, no built-in mechanism to handle processing failures and send to a separate queue unless you manually code it.
  • While you could add error handling, it's not as straightforward or automatic as using Lambda's on-failure destinations.

❌ Misuse of DynamoDB as an event ingestion point; lacks native failure routing.


Option D – ❌

  • EventBridge → EC2 via ALB.
  • EC2 Auto Scaling group behind ALB — can scale, but again, not as fine-grained or fast as Lambda.
  • EventBridge can retry, but if retries fail, sending to a dead-letter queue requires custom logic.
  • ALB is not a valid EventBridge target — EventBridge cannot target an ALB directly.
    • Valid targets include Lambda, SNS, SQS, Kinesis, EC2 (via EventBridge Pipes), Step Functions, etc., but not ALB.
  • So this architecture is not feasible.

❌ Invalid architecture (ALB not a valid EventBridge target), and uses less scalable EC2.


✅ Final Answer: A

It provides:

  • Automatic scaling via Lambda
  • Native error handling with on-failure destination to SQS for review

This is the most scalable, serverless, and correct solution.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.