AWS Certified Solutions Architect – Associate (SAA-C02) — Question 511
A solutions architect needs to design a solution that retrieves data every 2 minutes from a third-party web service that is accessible through the internet. A Python script runs the data retrieval in less than 100 milliseconds for each retrieval. The response is a JSON object that contains sensor data that is less than 1 KB in size. The solutions architect needs to store the JSON object along with the timestamp.
Which solution meets these requirements MOST cost-effectively?
Answer options
- A. Deploy an Amazon EC2 instance with a Linux operating system. Configure a cron job to run the script every 2 minutes. Extend the script to store the JSON object along with the timestamp in a MySQL database that is hosted on an Amazon RDS DB instance.
- B. Deploy an Amazon EC2 instance with a Linux operating system to extend the script to run in an infinite loop every 2 minutes. Store the JSON object along with the timestamp in an Amazon DynamoDB table that uses the timestamp as the primary key. Run the script on the EC2 instance.
- C. Deploy an AWS Lambda function to extend the script to store the JSON object along with the timestamp in an Amazon DynamoDB table that uses the timestamp as the primary key. Use an Amazon EventBridge (Amazon CloudWatch Events) scheduled event that is initiated every 2 minutes to invoke the Lambda function.
- D. Deploy an AWS Lambda function to extend the script to run in an infinite loop every 2 minutes. Store the JSON object along with the timestamp in an Amazon DynamoDB table that uses the timestamp as the primary key. Ensure that the script is called by the handler function that is configured for the Lambda function.
Correct answer: C
Explanation
AWS Lambda combined with Amazon DynamoDB is the most cost-effective solution because the execution time is extremely short (under 100 ms) and occurs only once every 2 minutes, which will incur virtually zero cost under the Lambda free tier. Triggering the function via Amazon EventBridge eliminates the need to run and pay for an idle EC2 instance. Additionally, DynamoDB is much more cost-effective for storing small, unstructured 1 KB payloads compared to maintaining a running Amazon RDS database instance.