0
votes

I've got an Azure WebJob which reads messages from a ServiceBus topic, and I'm looking for ways to speed it up. I've seen ways to do this with multiple factories and async methods, but these examples aren't for a WebJob, I'm not sure how this can be applied in a web job, any suggestions or links to relevant articles would be much appreciated!

The article I've seen with ideas to speed up using ServiceBus is here: https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-performance-improvements I think in a normal exe I could use the multiple factory and async ideas from this, but with a WebJob I have a method with a ServiceBusTrigger attribute, so I'm not sure if I can use the ideas in this article in the WebJob.

1
Using async/await will not make your code run faster, but it will allow your code to scale further. Async/await just ensures that while async operations are executing, the calling thread isn't blocked and waiting on the result. The thread is available to go do other things. When an async call returns, a thread is allocated to continue execution.Rob Reagan

1 Answers

2
votes

If you're using ServiceBusTrigger, you're pretty much locked into a single message receiver with a OnMessage handler set to concurrency that you'll configure. To gain throughput, you could use a NoAutomaticTrigger webjob and create your own infrastructure to handle message processing. With this approach you'd be able to create multiple message receivers with a factory (channel) per each, with concurrency set on each of the receivers. Async (in case you don't use it) would help as well as pointed out by @Rob.

The downsides of this approach is that you'd need to do everything yourself or use a 3rd party to provide you the middleware bits. NServiceBus or MassTransit are two options. NServiceBus has a show case that uses webjobs and Storage Queues that could be converted to use Service Bus.