Learn how to design and deploy a RESTful API that can handle data from IoT devices using AWS Lambda. Find out how to use unique identifiers and idempotency to prevent data inconsistencies or loss due to request throttling and retries.
Table of Contents
Question
A developer is creating an application that will be deployed on IoT devices. The application will send data to a RESTful API that is deployed as an AWS Lambda function. The application will assign each API request a unique identifier. The volume of API requests from the application can randomly increase at any given time of day.
During periods of request throttling, the application might need to retry requests. The API must be able to handle duplicate requests without inconsistencies or data loss.
Which solution will meet these requirements?
A. Create an Amazon RDS for MySQL DB instance. Store the unique identifier for each request in a database table. Modify the Lambda function to check the table for the identifier before processing the request.
B. Create an Amazon DynamoDB table. Store the unique identifier for each request in the table. Modify the Lambda function to check the table for the identifier before processing the request.
C. Create an Amazon DynamoDB table. Store the unique identifier for each request in the table. Modify the Lambda function to return a client error response when the function receives a duplicate request.
D. Create an Amazon ElastiCache for Memcached instance. Store the unique identifier for each request in the cache. Modify the Lambda function to check the cache for the identifier before processing the request.
Answer
B. Create an Amazon DynamoDB table. Store the unique identifier for each request in the table. Modify the Lambda function to check the table for the identifier before processing the request.
Explanation
The correct answer is B. Create an Amazon DynamoDB table. Store the unique identifier for each request in the table. Modify the Lambda function to check the table for the identifier before processing the request.
This solution will meet the requirements because it will allow the API to handle duplicate requests without inconsistencies or data loss. Amazon DynamoDB is a fully managed NoSQL database service that provides fast and consistent performance with seamless scalability. Amazon DynamoDB supports conditional writes, which means that an item will be written only if a specified condition is met. The developer can create a DynamoDB table with the unique identifier as the primary key and use a conditional write to store the identifier for each request. The developer can modify the Lambda function to check the table for the identifier before processing the request. If the identifier already exists, the function can skip the request or return a success response without performing any operation.
The other options are not optimal or efficient for the following reasons:
A. Creating an Amazon RDS for MySQL DB instance and storing the unique identifier for each request in a database table will not meet the requirements, as it will introduce additional complexity and overhead to the application. The developer will have to manage and maintain the RDS instance, the database connection, and the SQL queries. The developer will also have to handle potential concurrency issues or conflicts when multiple requests try to write or read from the same table.
C. Creating an Amazon DynamoDB table and storing the unique identifier for each request in the table will not meet the requirements, as it will not handle duplicate requests gracefully. Modifying the Lambda function to return a client error response when it receives a duplicate request will cause unnecessary failures and retries for the application. The application might interpret the error response as a throttling error and keep retrying until it succeeds or times out.
D. Creating an Amazon ElastiCache for Memcached instance and storing the unique identifier for each request in the cache will not meet the requirements, as it will not provide durability or consistency guarantees for the data. Amazon ElastiCache is a service that provides in-memory data stores for applications. Memcached is a simple key-value store that supports basic data types, such as strings, numbers, and binary data. Memcached does not support persistence, replication, or transactions, which means that data can be lost or corrupted due to network failures, power outages, or node crashes.
The latest AWS Certified Developer – Associate DVA-C02 certification actual real practice exam question and answer (Q&A) dumps are available free, which are helpful for you to pass the AWS Certified Developer – Associate DVA-C02 exam and earn AWS Certified Developer – Associate DVA-C02 certification.