DEA-C01 Question 109
Select 4A company processes streaming data from IoT sensors using AWS Kinesis Data Streams. You need to implement a Lambda function that processes each record and sends alerts when the sensor readings exceed a specific threshold. Which of the following programming concepts and techniques should you apply to ensure proper functionality and efficiency?
- A
Deserialize JSON data from Kinesis records before processing.
- B
Use a retry mechanism within the Lambda function to handle potential processing errors.
- C
Hardcode the threshold value directly within the Lambda function code.
- D
Implement a batch processing mechanism to handle multiple records at once.
- E
Use environment variables to dynamically configure the threshold value.
Show answer and explanation
Correct answers: A, B, D, E
Explanation
To process streaming data efficiently and effectively, you must apply programming concepts such as deserializing input data, implementing retry mechanisms for error handling, and leveraging batch processing to handle multiple records together. Additionally, using environment variables for configuration, rather than hardcoding values, ensures flexibility in managing and updating application settings. These concepts align with best practices for implementing serverless architectures on AWS.
- A. Correct.
Deserializing JSON data is essential for extracting and processing meaningful information from the Kinesis records. This is a basic programming concept when dealing with JSON-formatted data.
- B. Correct.
A retry mechanism is crucial for handling transient errors or issues while processing records in Lambda. This ensures resilience and reliability in processing.
- C. Incorrect.
Hardcoding the threshold value is not a best practice as it makes the system inflexible and harder to maintain. Configuration should be externalized, such as using environment variables.
- D. Correct.
Batch processing of records from Kinesis can improve efficiency by reducing the number of invocations and enabling bulk processing, which is a common technique in stream processing.
- E. Correct.
Using environment variables allows for dynamic configuration of the threshold value, making the solution more flexible and easier to update without modifying the code.