Exam DVA-C02 All QuestionsBrowse all questions from this exam
Question 74

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?

    Correct Answer: B

    To ensure an accurate calculation of the rolling average, the function should use a reliable mechanism to maintain state across multiple invocations. By storing the values in Amazon ElastiCache, the Lambda function can persist the results of previous executions. When the function initializes, it can then retrieve these values and include them in the calculation, ensuring continuity and accuracy. This approach takes advantage of ElastiCache's speed and in-memory capabilities, allowing the function to quickly access and update the state needed for precise computations. The alternative approaches that involve setting reserved or provisioned concurrency to 1 (options A and C) are less efficient and can severely limit the function's throughput, making them less suitable for scalable applications.

Discussion
eboehmOption: 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

jipark

reserve concurrency 1 means poll in order. this looks answer.

MrTeeOption: 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.

ShinobiGrapplerOption: 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.

SerialiDrOption: 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.

d323bvmiqjOption: 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 ?

chewasaOption: 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.

Certified101Option: A

A is correct

JonalbOption: A

Ao definir a simultaneidade reservada da função como 1, isso garante que apenas uma instância da função Lambda será invocada ao mesmo tempo. Isso pode ajudar a evitar qualquer problema de concorrência que possa causar imprecisões na média móvel. Ao calcular a média móvel na função e armazená-la no Amazon ElastiCache, a função pode acessar e atualizar rapidamente a média sempre que for invocada.

65703c1Option: A

A is the correct answer.

yingying920928Option: 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.

maurice2005

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.

SerialiDrOption: 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.

lozouOption: B

elasticache for keeping the values from previous invocation

guidosolanoOption: B

A y C limitan mucho la capacidad de Lamda. Voy con B

SathyaJS

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.

ChimziOption: B

Using ElastiCache allows you to maintain a shared state across all instances of your Lambda function

[Removed]

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.

[Removed]

Actually after reading the question more carefully... I change my answer to B

tqiu654Option: B

ChatGPT:B

beekeeper0101

ChatGPT is not the bible for aws