Q64 — AWS SAA-C03 Ch.13

Question 64 of 100 | ← Chapter 13

Q964. A company is migrating from a monolithic architecture for a web application that is hosted on Amazon EC2 to a serverless microservices architecture.The company wants to use AWS services that support an event- driven,loosely coupled architecture.The company wants to use the publish/subscribe (pub/sub) pattern. Which solution will meet these requirements MOST cost-effectively?

Correct Answer: B. Configure an Amazon API Gateway REST API to invoke an AWS Lambda function that publishes events to an Amazon Simple Notification Service (Amazon SNS) topic. Configure one or more subscribers to receive events from the SNS topic.

Explanation

The solution that meets the requirements most cost-effectively is B. Configure an Amazon API Gateway REST API to invoke an AWS Lambda function that publishes events to an Amazon Simple Notification Service (Amazon SNS) topic. Configure one or more subscribers to receive events from the SNS topic.Here's why:Event-Driven Architecture: SNS is a fully managed pub/sub service that allows for loosely coupled communication between different components of the application. Cost-Effective: SNS is a cost-effective solution, especially for high-volume event publishing and subscription. It charges only for the messages published and received. Scalability: SNS can handle a high volume of events and scales automatically to meet demand. Loose Coupling: SNS enables independent scaling and development of different microservices, as they don't need to be directly connected.API Gateway Integration: API Gateway provides a secure and scalable way to expose the application's API endpoints, allowing clients to trigger events.Why other options are less suitable:A. Configure an Amazon API Gateway REST API to invoke an AWS Lambda function that publishes events to an Amazon Simple Queue Service (Amazon SQS) queue. Configure one or more subscribers to read events from the SQS queue: While SQS is a good option for queuing messages, it's not as efficient for pub/sub scenarios as SNS. SQS is designed for point-to-point communication, while SNS is optimized for one-to-many communication.C. Configure an Amazon API Gateway WebSocket API to write to a data stream in Amazon Kinesis Data Streams with enhanced fan-out. Configure one or more subscribers to receive events from the data stream: Kinesis Data Streams is designed for real-time data processing and streaming, not for general- purpose event publishing and subscription. It might be overkill for this scenario and can be more expensive than SNS.D. Configure an Amazon API Gateway HTTP API to invoke an AWS Lambda function that publishes events to an Amazon Simple Notification Service (Amazon SNS) topic. Configure one or more subscribers to receive events from the topic: This is essentially the same solution as option B, with the only difference being the type of API Gateway API used. Both HTTP and REST APIs can be used to invoke Lambda functions.In summary:Option B provides the most cost-effective and efficient way to implement an event-driven, loosely coupled architecture using the pub/sub pattern. SNS is a well-suited service for this scenario, offering scalability, cost-effectiveness, and seamless integration with API Gateway and Lambda functions.