节流:仅在队列触发的Azure功能完成后才删除队列消息吗?
剧透:似乎没有,所以我想知道如何做到这一点.
Spoiler: It doesn't seem to, so I want to know how to accomplish this.
在这种情况下,我需要进行大量工作(就我而言,是图像处理并向数据库报告),我想使用Azure函数进行处理.问题是,如果我产生太多实例,我的Azure SQL数据库很快就会不知所措 并超时.因此,我需要做的是限制Azure Function的并发实例的数量.
I have a situation in which I have a large batch of work (in my case, image processing and reporting to a database) I want processed using an Azure Function. The problem is that if I spawn too many instances, my Azure SQL Database quickly gets overwhelmed and times out. So what I need to do is throttle the number of concurrent instances of the Azure Function.
我已经尝试使用Queue Storage + Queue Trigger作为该功能.我将图像上传到Blob存储,然后将消息添加到队列中,描述此上传,该消息成功触发了Azure功能.但是尽管有各种批处理大小 /newBatchThreshold/maxDequeueCount设置我尝试过,似乎仍然会同时产生太多的函数实例,并且Azure SQL数据库不可避免地会超时.
I've tried making use of Queue Storage + Queue Trigger for the function. I upload an image to blob storage, then add a message to a Queue describing this upload which successfully triggers the Azure Function. But despite the various batchSize / newBatchThreshold / maxDequeueCount settings I've tried, it still seems that too many function instances spawn at once and the Azure SQL database calls inevitably time out.
所以我的问题之一是:是否仅在函数实例完成后才从队列中删除消息,还是只是将消息从队列中拉出并且函数尽快运行?我正试图以一种可靠的方式来减慢速度, 但我仍然不知道如何做到这一点.
So one of my questions is: Does the message removal from the queue happen only after a function instance completes, or do messages just get pulled off the queue and functions run as quickly as possible? I'm trying to slow this down in a reliable way, but I still can't tell how to accomplish this.
嘿,迈克-您是否使用
Hey Mike - Have you explored using Azure Event Hub instead? It might be more fitting to your scenario since it's designed to decouple event consumers from the event publishers.