0

I have an Azure durable function (HttpTrigger -> orchestrator -> activity) which is called from 2 sources - automated and manually. When called automatically, multiple calls are queued and then executed. When calling the function manually, the manual call is also queued and will be executed at some time in the future (after all queued automated calls are executed). What I would like to do is to prioritize the manual call in such a way that it is the next to be processed, so it has a higher priority than the automated calls.

Is there a way to do this?

juunas
  • 54,244
  • 13
  • 113
  • 149
Bogdan Banut
  • 101
  • 1
  • 6
  • So do you have a queue triggered function in between that is configured to execute messages in series? – juunas Sep 08 '20 at 10:45
  • Or is it that the orchestrator executions themselves are waiting for previous ones to complete? (since that uses a queue as well) – juunas Sep 08 '20 at 10:48
  • I want the manual call to be executed asap, instead of waiting for the automated calls to be processed first – Bogdan Banut Sep 08 '20 at 10:59
  • Yes I read your question. But do you start your orchestrator from your HttpTrigger function? – juunas Sep 08 '20 at 11:04
  • Yes, both the manual and automated calls trigger a HttpTrigger function. This function in turn calls the orchestrator: await starter.StartNewAsync("xxxOrchestrator", model); The orchestrator triggets the activity function, one instance per customer profile (the automated trigger processes multiple profiles, the manual only one) model.Profiles.Select(p => context.CallActivityAsync(nameof(xxxActivity), new xxxModel) And then the activity function does the actual processing. Hope it's clearer now, thanks for your patience! – Bogdan Banut Sep 08 '20 at 11:13
  • So the problem is that those activities are not started soon enough for these manually started ones? – juunas Sep 08 '20 at 12:31
  • Yes Juunas, that is exactly the problem. The manual triggers are exceptional and I need them to be executed immediately/asap, instead of being queued and waiting for multiple automated triggers to be completed first. – Bogdan Banut Sep 09 '20 at 06:10
  • Are you running on a consumption plan in Azure Functions? Activities _should_ scale to run on as many instances as required, and this kind of thing shouldn't be much of an issue. If you need to have different priority for these, you might need a different work item queue (which is used for triggering activities). That means you would need a different _task hub_, which essentially means running a second Azure Function for the priority ones, possibly in a different Storage account. – juunas Sep 09 '20 at 07:17
  • Thank you for the suggestion! The issue is that my activity calls an external service. This service can only deal with a maximum of 4 activities at a time (performance-wise). For the automated triggers we have implemented the fan out - fan in pattern, and this is how we can control the maximum number of parallel instances. Because of the external service limitations, we do NOT want to allow an uncontrolled number of activity instances to be executed at the same time. – Bogdan Banut Sep 11 '20 at 09:04
  • Regarding the idea of having a second Azure Function, this would indeed allow us to trigger the execution whenever we want, but there are 2 main issues with this: 1. We could no longer control the maximum number of instances running in parallel. If we trigger more than 4, the external service will crash, and all activities will fain. 2. I don't really like the idea of having duplicate Azure Functions because of duplicate code/deployment complications. – Bogdan Banut Sep 11 '20 at 09:04
  • So ideally what I am looking for is: when triggering an azure function activity instance, can we specify that it should have a higher priority than other activity instances? – Bogdan Banut Sep 11 '20 at 09:04
  • 1
    No, you cannot. – juunas Sep 11 '20 at 09:17

0 Answers0