You are a team lead for the development of an application that will be hosted in AWS.
The application will consist of a front end that will allow users to upload files.
Part of the application will consist of sending and processing of messages by a backend service.
You have been told to reduce the cost for the backend service but also ensure efficiency.
Which of the following would you consider in the implementation of the backend service? Choose 2 answers from the options given below.
Click on the arrows to vote for the correct answer
A. B. C. D.Answer - A and C.
The SQS queue can be used to handle the sending and receiving of messages.
To reduce costs, you can use Lambda functions to process the messages.
The below is also given in the AWS Documentation.
Using AWS Lambda with Amazon SQS.
Attaching an Amazon SQS queue as an AWS Lambda event source is an easy way to process the queue's content using a Lambda function.
Lambda takes care of:
Automatically retrieving messages and directing them to the target Lambda function.
Deleting them once your Lambda function successfully completes.
Option B is incorrect since you should use SQS for the handling of messages.
SNS has no persistence.
Whichever consumer is present at the time of message arrival, get the message and the message is deleted.
If no consumers available, then the message is lost.
Option D is incorrect since this would not be a cost-effective option.
For more information on working with SQS, please refer to the below URL-
https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.htmlGood Discussion on StackOverflow here- : https://stackoverflow.com/questions/13681213/what-is-the-difference-between-amazon-sns-and-amazon-sqs.
The two options that would be considered in the implementation of the backend service to reduce cost but ensure efficiency are:
A. Create an SQS queue to handle the processing of messages. C. Create a Lambda function to process the messages from the queue.
Explanation:
A. Create an SQS queue to handle the processing of messages: Amazon Simple Queue Service (SQS) is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications. SQS eliminates the complexity and overhead associated with managing and operating message oriented middleware, and empowers developers to focus on differentiating work. By using SQS to handle the processing of messages, you can reduce the cost of running a backend service because SQS is a fully managed service and you only pay for what you use. Additionally, it ensures efficiency because SQS is designed to handle any volume of messages, and it allows for message delivery between distributed application components and microservices, which can help in scaling and managing the application.
C. Create a Lambda function to process the messages from the queue: AWS Lambda is a compute service that lets you run code without provisioning or managing servers. Lambda automatically scales and runs your code in response to each trigger, ensuring that you only pay for the compute time that you consume. By creating a Lambda function to process the messages from the queue, you can reduce the cost of running a backend service because you only pay for the compute time that the function uses, which can be less expensive than running a dedicated server or EC2 instance. Additionally, Lambda ensures efficiency because it can be triggered by events, such as messages in an SQS queue, and it can process the messages in parallel, which can help in handling high volumes of messages.
D. Create an EC2 Instance to process the messages from the queue: Amazon Elastic Compute Cloud (EC2) is a web service that provides resizable compute capacity in the cloud. By creating an EC2 instance to process the messages from the queue, you can have more control over the environment in which the messages are processed. However, this option may not be the most cost-effective option, because you need to pay for the EC2 instance and the associated infrastructure costs, such as storage and network bandwidth. Additionally, you need to manage the EC2 instance yourself, which can be time-consuming and require more resources. Therefore, this option does not help in reducing the cost of running a backend service, but it can ensure efficiency if you need more control over the environment in which the messages are processed.
B. Create an SNS topic to handle the processing of messages: Amazon Simple Notification Service (SNS) is a fully managed messaging service for both application-to-application (A2A) and application-to-person (A2P) communication. SNS enables you to create topic to which multiple recipients can subscribe and receive published messages. While SNS is useful for broadcasting messages to multiple endpoints, it does not provide a queuing mechanism to handle message processing or to ensure reliable message delivery. Therefore, it is not an appropriate option to handle the processing of messages in this scenario.
In conclusion, options A and C would be considered in the implementation of the backend service to reduce cost but ensure efficiency.