Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
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 (?) , you can switch to a simple comment.
Switch to a voting comment New
eboehm
Highly Voted 1 year, 5 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, 3 months ago
reserve concurrency 1 means poll in order. this looks answer.
upvoted 2 times
...
...
MrTee
Highly Voted 1 year, 6 months 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 18 times
...
AmitRanchi
Most Recent 1 month, 1 week 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
3 months, 1 week 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_
2 weeks, 2 days ago
layers are not meant to store dynamic data. it's for sharing libraries and static code across lambda functions
upvoted 1 times
...
...
lozou
4 months, 1 week ago
Selected Answer: B
elasticache for keeping the values from previous invocation
upvoted 1 times
...
guidosolano
4 months, 2 weeks ago
Selected Answer: B
A y C limitan mucho la capacidad de Lamda. Voy con B
upvoted 1 times
...
65703c1
5 months, 3 weeks ago
Selected Answer: A
A is the correct answer.
upvoted 2 times
...
SathyaJS
7 months, 3 weeks 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
8 months 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
7 months, 3 weeks 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
8 months, 3 weeks 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
9 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
10 months, 1 week 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
10 months, 1 week ago
Selected Answer: B
Using ElastiCache allows you to maintain a shared state across all instances of your Lambda function
upvoted 1 times
...
ShinobiGrappler
11 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
...
chewasa
11 months ago
Selected Answer: B
Both options A and B provide valid approaches to address potential issues, but they have different trade-offs. Option A focuses on limiting concurrency, while Option B suggests using a caching solution to store and retrieve intermediate values. If avoiding concurrency problems is a top priority and the function's execution time is not a concern, Option A could be a suitable choice. However, if you are looking for a solution that allows for better scalability and doesn't impose strict concurrency limitations, Option B with Amazon ElastiCache provides a more scalable and distributed approach.
upvoted 4 times
...
Certified101
11 months ago
Selected Answer: A
A is correct
upvoted 3 times
...
[Removed]
11 months, 1 week ago
Another tricky question. I go with A mainly because ElastiCache is mainly used along with databases. See this link https://docs.aws.amazon.com/lambda/latest/dg/lambda-concurrency.html#reserved-and-provisioned Pulled from AWS Website --> What is Amazon ElastiCache? Amazon ElastiCache allows you to seamlessly set up, run, and scale an in-memory cache in the cloud. ElastiCache is compatible with both Redis and Memcached. Boost your application performance and achieve microsecond latency by caching alongside your existing databases. ElastiCache is a popular choice for real-time use cases like caching, session stores, gaming, geo-spatial services, real-time analytics, and queuing.
upvoted 1 times
[Removed]
11 months, 1 week ago
Actually after reading the question more carefully... I change my answer to B
upvoted 1 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 ...