exam questions

Exam AWS Certified Developer - Associate DVA-C02 All Questions

View all questions & answers for the AWS Certified Developer - Associate DVA-C02 exam

Exam AWS Certified Developer - Associate DVA-C02 topic 1 question 74 discussion

A developer created an AWS Lambda function that accesses resources in a VPC. The Lambda function polls an Amazon Simple Queue Service (Amazon SQS) queue for new messages through a VPC endpoint. Then the function calculates a rolling average of the numeric values that are contained in the messages. After initial tests of the Lambda function, the developer found that the value of the rolling average that the function returned was not accurate.

How can the developer ensure that the function calculates an accurate rolling average?

  • A. Set the function's reserved concurrency to 1. Calculate the rolling average in the function. Store the calculated rolling average in Amazon ElastiCache.
  • B. Modify the function to store the values in Amazon ElastiCache. When the function initializes, use the previous values from the cache to calculate the rolling average.
  • C. Set the function's provisioned concurrency to 1. Calculate the rolling average in the function. Store the calculated rolling average in Amazon ElastiCache.
  • D. Modify the function to store the values in the function's layers. When the function initializes, use the previously stored values to calculate the rolling average.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
eboehm
Highly Voted 1 year, 10 months ago
Selected Answer: A
You need to set the reserved concurrency to 1 otherwise multiple functions could run at the same time causing the math to be off. Also there was a similar question in another practice exam set that stated the same thing
upvoted 25 times
jipark
1 year, 9 months ago
reserve concurrency 1 means poll in order. this looks answer.
upvoted 2 times
...
...
MrTee
Highly Voted 2 years ago
Selected Answer: B
By using ElastiCache, the Lambda function can store the values of the previous messages it has received, which can be used to calculate an accurate rolling average.
upvoted 19 times
...
sumanshu
Most Recent 4 months ago
Selected Answer: A
B) Eliminated - If multiple instances of the Lambda function run concurrently, they could retrieve or modify the same data in ElastiCache, leading to inaccuracies in the rolling average. C) Eliminated - Provisioned concurrency does not prevent concurrency issues D) Eliminated - Lambda layers are used to share common code or dependencies across Lambda functions but are not designed for storing or persisting data.
upvoted 2 times
...
ShakthiGCP
4 months, 1 week ago
Selected Answer: B
Reserved concurrency: Setting reserved concurrency to 1 ensures only one instance of the function executes at a time. While this might prevent race conditions, it doesn't address the core issue of calculating the rolling average across multiple Lambda invocations. u
upvoted 1 times
...
trieudo
4 months, 1 week ago
Selected Answer: A
==> Discard B: There are not limit corrency in elastic cache, multiple lambda can access make race condition ==> wrong output
upvoted 1 times
...
AmitRanchi
6 months, 3 weeks ago
Selected Answer: A
Reserved Concurrency of 1 ensures that only one instance of the Lambda function runs at a time, which is crucial for calculating an accurate rolling average. If multiple instances of the Lambda function run simultaneously (without concurrency control), each instance might have incomplete or inconsistent data, leading to incorrect results for the rolling average. Storing the rolling average in Amazon ElastiCache provides a persistent, in-memory storage that the function can access quickly during each invocation. ElastiCache can store the current state of the rolling average and any relevant historical data, ensuring that each invocation of the Lambda function has access to the most recent values for calculation
upvoted 1 times
...
Saurabh04
8 months, 3 weeks ago
Correct answer should be D. Storing values in the function's layers and using them during initialization is straightforward. This Approach avoids external services like Elasticache.
upvoted 1 times
rue_
6 months ago
layers are not meant to store dynamic data. it's for sharing libraries and static code across lambda functions
upvoted 1 times
...
...
lozou
9 months, 3 weeks ago
Selected Answer: B
elasticache for keeping the values from previous invocation
upvoted 1 times
...
guidosolano
10 months ago
Selected Answer: B
A y C limitan mucho la capacidad de Lamda. Voy con B
upvoted 1 times
...
65703c1
11 months, 1 week ago
Selected Answer: A
A is the correct answer.
upvoted 2 times
...
SathyaJS
1 year, 1 month ago
Selected Answer: B As per Gemini below is why A is incorrect A. Reserved concurrency: Setting reserved concurrency to 1 ensures only one instance of the function executes at a time. While this might prevent race conditions, it doesn't address the core issue of calculating the rolling average across multiple Lambda invocations.
upvoted 1 times
...
yingying920928
1 year, 1 month ago
Selected Answer: B
While limiting concurrency (A or C) can help manage the function's execution rate and scale and prevent throttling, it is not directly related to ensuring the accuracy of calculating rolling average. Instead, focusing on proper state management and data consistency mechanisms (using ElastiCache) is key to achieving accurate results in this scenario.
upvoted 2 times
maurice2005
1 year, 1 month ago
that's the correct way in real world but nothing about state management or data consistency is mentioned in B. But A has it although it's not the good real world to do so.
upvoted 1 times
...
...
SerialiDr
1 year, 2 months ago
Selected Answer: A
Option A ("Set the function's reserved concurrency to 1. Calculate the rolling average in the function. Store the calculated rolling average in Amazon ElastiCache.") is the most suitable solution. It ensures that only one instance of the Lambda function processes messages at any given time, maintaining the sequence of message processing which is crucial for an accurate rolling average calculation. Additionally, using Amazon ElastiCache to store and retrieve the rolling average across invocations addresses the statelessness of AWS Lambda, enabling stateful processing.
upvoted 4 times
...
d323bvmiqj
1 year, 2 months ago
Selected Answer: A
What if one of the instances freezes and holds one of the vzlues for some time, not updating cache, while the others continue calculatinv the avg giving wrong output ?
upvoted 3 times
...
SerialiDr
1 year, 3 months ago
Selected Answer: B
By storing individual message values in ElastiCache (a fast, in-memory data store), the Lambda function can retrieve these values upon initialization to calculate an accurate rolling average. This approach effectively maintains state across Lambda invocations.
upvoted 2 times
...
Chimzi
1 year, 3 months ago
Selected Answer: B
Using ElastiCache allows you to maintain a shared state across all instances of your Lambda function
upvoted 1 times
...
ShinobiGrappler
1 year, 4 months ago
Selected Answer: A
This approach controls concurrency by ensuring only one instance runs at a time. Provisioned concurrency also has the added benefit of reducing cold start latency. Storing the rolling average in ElastiCache is a good practice for maintaining state. However, like option A, it may limit the function's throughput.
upvoted 4 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago