1

Suppose I have an Azure Function App in a Consumption Plan listening on an Azure Event Hub. According to this documentation, the number of function app instances can scale down to 0 if there are no incoming events. In my understanding, every function app instance also instantiates an Event Processor Host which is listening on partitions of the event hub. But if the number of instances is 0, who is then listening on the event hub to determine if messages must be processed? Does an Event Processor Host exist when the number of instances of a function is 0? Here is the (incomplete) picture I have so far about Azure Functions + Azure Event Hubs which I'd like to complete: enter image description here

In said documentation I also read about the scale controller which apparently adds new function host instances when needed. Does this mean, the scale controller must also listen on the event hub? Where is the scale controller located, is it part of the function app resource I can create in Azure or is the scale controller hosted in an isolated part of Azure independent of the existence of my function app?

Edit: Adopted image based on answers.

Christian Vorhemus
  • 2,396
  • 1
  • 17
  • 29
  • "Does an Event Processor Host exist when the number of instances of a function is 0?" Yes. *Something* has to be listening to messages at all times to know if a function should be spun up. – Ian Kemp Feb 25 '21 at 11:00
  • 1
    In the interest of being pedantic, the scale controller does not use an `EventProcessorHost`. It uses an `EventHubClient` to query the partitions of an Event Hub and compare them to the checkpoints that exist to understand how deep the event backlog is. – Jesse Squire Feb 25 '21 at 14:43

1 Answers1

2

This is what the managed Function runtime on Azure is doing for you. It listens to the Event Hub (or Service Bus, or other supported trigger sources) for you - and you do not have to pay for that compute. Once it detects new messages, it will spin up one or more instances of your Function - at which point only the billing starts.

enter image description here

Source

If you are running Functions somewhere else, e.g. in a k8s cluster, you have to host the scale controller yourself and keep it running all the time.

silent
  • 14,494
  • 4
  • 46
  • 86
  • Thank you for your answer. I've adopted the graphical visualization, can you check if my understanding is correct as for now? – Christian Vorhemus Feb 25 '21 at 13:56
  • can't give an authoritive answer but looks about right conceptually. I think there are some talks about there where they describe the underlying architecture but cannot find them right now – silent Feb 25 '21 at 14:42
  • https://www.researchgate.net/figure/Azure-Functions-architecture_fig4_337362540 – silent Feb 25 '21 at 14:43