exam questions

Exam AZ-204 All Questions

View all questions & answers for the AZ-204 exam

Exam AZ-204 topic 5 question 9 discussion

Actual exam question from Microsoft's AZ-204
Question #: 9
Topic #: 5
[All AZ-204 Questions]

You are developing an Azure function that connects to an Azure SQL Database instance. The function is triggered by an Azure Storage queue.
You receive reports of numerous System.InvalidOperationExceptions with the following message:
`Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.`
You need to prevent the exception.
What should you do?

  • A. In the host.json file, decrease the value of the batchSize option
  • B. Convert the trigger to Azure Event Hub
  • C. Convert the Azure Function to the Premium plan
  • D. In the function.json file, change the value of the type option to queueScaling
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
VK7Az204
Highly Voted 4 years, 1 month ago
A is the correct answer
upvoted 75 times
...
djffcnhhyiyaigyvuy
Highly Voted 4 years, 1 month ago
The error shown is a SQL Server error not an Azure functions error. https://forums.asp.net/t/2004198.aspx?Timeout+expired+The+timeout+period+elapsed+prior+to+obtaining+a+connection+from+the+pool+This+may+have+occurred+because+all+pooled+connections+were+in+use+and+max+pool+size+was+reached+ The actual issue appears to be that you have too many simultaneous functions running, the solution is to limit the batch size (# functions that can run in parallel) https://social.msdn.microsoft.com/Forums/azure/en-US/a2955297-1c14-45f2-b799-6346b340519a/how-does-batchsize-works-in-hostjson?forum=AzureFunctions
upvoted 30 times
rdemontis
4 years, 1 month ago
Correct! We have to consider we are speaking about Azure Function with Azure Storage Queue Trigger. This is a case where execution could happens in parallel based on the queue batchSize property (see https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue). I think this is the batchSize property referred in the question (and not that in the functions aggregator. That's another thing). Besides, we have to consider the origin of the error message: Azure Sql Database!! So upgrading the plan the problem could only get worse thing.
upvoted 8 times
coffecold
2 years, 6 months ago
This article explains well and easy : https://medium.com/@hammadarif/throttling-the-scalability-of-azure-functions-v2-ddb8625eeedc It gives also the answer why upgrading to premium won't help.
upvoted 1 times
coffecold
2 years, 6 months ago
B.t.w usage in host.json : { "queues": { "batchSize": 1, "newBatchThreshold": 7 } } It has nothing to do with the aggrator batchsize
upvoted 2 times
...
...
...
...
Vichu_1607
Most Recent 5 months, 1 week ago
Selected Answer: A
A. In the host.json file, decrease the value of the batchSize option
upvoted 2 times
...
NPE_
1 year, 6 months ago
The answer should be A. The error message shows that there is not enough connections, which means that the concurrency is too high. Too many instances are running parallel. So we have to reduce the concurrency of the app. https://github.com/Azure/azure-functions-host/wiki/host.json If you search for "batchSize" on the above official microsoft github wiki page for host.json, you will find the explanation for the batchSize: // The number of queue messages to retrieve and process in // parallel (per job function). The default is 16 and the maximum is 32. "batchSize": 16,
upvoted 1 times
...
Lola2023
1 year, 7 months ago
Selected Answer: C
Explanation: With the Premium plan the max outbound connections per instance is unbounded compared to the 600 active (1200 total) in a Consumption plan. Note: The number of available connections is limited partly because a function app runs in a sandbox environment. One of the restrictions that the sandbox imposes on your code is a limit on the number of outbound connections, which is currently 600 active (1,200 total) connections per instance. When you reach this limit, the functions runtime writes the following message to the logs: Host thresholds exceeded: Connections.
upvoted 1 times
...
BaoNguyen2411
1 year, 9 months ago
got this question on 29/06/2023
upvoted 3 times
macobuzi
1 year, 8 months ago
What option did you choose?
upvoted 2 times
...
...
JOSEEVILLASMIL
2 years, 1 month ago
Answer A, the error is at SQL Instance no a function error, and the questions does not say the plan you have... so you cannot asume that you are using consumtion plan.
upvoted 2 times
...
Sriniv
2 years, 2 months ago
None of the options provided are correct I think
upvoted 1 times
...
Sriniv
2 years, 2 months ago
the most appropriate solution in this case is to optimize the function code and increase the Max Pool Size property of the connection string used by the function.
upvoted 1 times
...
alexein74
2 years, 3 months ago
Selected Answer: A
A is the correct answer
upvoted 1 times
...
OPT_001122
2 years, 5 months ago
Selected Answer: A
A is the correct answer
upvoted 3 times
...
gmishra88
2 years, 6 months ago
This is a question for a machine. I have to remember all options in host.json. How many of these random questions can be asked by Microsoft. https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messages-payloads https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messages-payloads https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messages-payloads https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messages-payloads https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messages-payloads https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#aggregator According to the above link batchSize is about application insights. Another marvel from Microsoft to make it without application insights anywhere and cherry on top to ask that mistake in an exam. Especially when batching will make people think it has something to do with batching the calls. Microsoft wins again https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#aggregator
upvoted 3 times
gmishra88
2 years, 6 months ago
This is the way to limit scale out, but guess that is not there in the options https://learn.microsoft.com/en-us/azure/azure-functions/event-driven-scaling#limit-scale-out
upvoted 1 times
...
gmishra88
2 years, 6 months ago
And yes, there is another batchSize that could be for the storage queue. But then we have to imagine that could be the unwritten scenario.
upvoted 1 times
...
...
Knightie
2 years, 7 months ago
it can not be C when Pool connection is running out, it's able the DB connections pool is out, changing the function plan only allow more callers to access the DB but it does not increase the connections pool size, so it will still be out of connections in DB.
upvoted 1 times
...
Knightie
2 years, 8 months ago
Selected Answer: A
It's the DB connection Pool..... you scale up the app also no use.. the connectors from DB Pool not release fast enough for the next app to operate.
upvoted 2 times
...
Dani_ac7
2 years, 9 months ago
Selected Answer: A
A is the correct answer
upvoted 2 times
...
meoukg
3 years, 1 month ago
Got it on 03/2022, I chose A. In the host.json file, decrease the value of the batchSize option
upvoted 4 times
...
ReniRechner
3 years, 1 month ago
Selected Answer: C
A: seems not correct for me. see: https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json#aggregator it just seems to affect metrics. Besides an increase would help => more elements per function => less functions => less connections B: might help (if scaling can be limited), but for itself is not a solution C: does not help since source of problem (to many incoming connections to SQL Server) unchanged. There is no problem with number of outgoing connections in function D: searching for "queueScaling" only resulted in AZ-204 question results ;-) So what should I choose? While doing research for point B I git to this site https://medium.com/microsoftazure/azure-functions-limiting-throughput-and-scalability-of-a-serverless-app-5b1c381491e3 I found the hint that a premium plan can limit instances, which is verified here: https://docs.microsoft.com/en-us/azure/azure-functions/functions-premium-plan?tabs=portal#maximum-function-app-instances So I would go with C but for the option to limit scaling and not for the explanation in the result.
upvoted 1 times
iamstudying
3 years, 1 month ago
I agree with your reason for not A.. batching is supposed to reduce number of IO requests and thus connections to SQL DB The Medium post you referenced is outdated. You can actually limit the scaling on both Consumption and Premium plans: https://docs.microsoft.com/en-us/azure/azure-functions/event-driven-scaling#limit-scale-out I don't think there is a right answer here... pick A and prAy, buddies
upvoted 2 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