Search code examples
azureazure-functionseventhub

Azure Event Hub Processor: WebJob or AzureFunction?


I have an Azure Event Hub with 8 partitions. It gets about 15K-20K events per day. Doesn't do much processing, mostly passes messages to various queues to be processed by Azure Functions triggered on the queues. I'm updating everything from (deprecated) Microsoft.ServiceBus.Messaging to Azure.Messsaging.ServiceBus. My question is, for decent throughput (not critical), am I ok with creating an AzureFunction with an EventHubTrigger (easier) or should I create a new Webjob with a few (say 8) EventProcesserClient instantiations (better throughput)? It's all running under an Azure App Service Plan that is running 1-2 instances based on Time-of-Day.


Solution

  • Given the volume of transactions, a function should be sufficient. They can scale out automatically if you have large bursts of messages, too.

    If performance is your main concern:

    • Ensure your events are distributed across the 8 partitions using a good partition key. This helps in balancing the load across multiple instances of the function
    • Configure batch processing in the function so it can deal with multiple events at once, using EvantData[] events ... foreach (EventData event in events) ...
    • Adjust the maxConcurrentCalls and prefetchCount in host.json to suit your requirements
    • Configure App Service Plan Premium tier auto-scaling, if necessary