Azure Service Bus - Completemessageasync running slow

Stefan 191 Reputation points
2022-05-11T15:49:12.35+00:00

Hi,

I have been doing some tests reading from a Azure Service Bus Queue using the library Azure.Messaging.ServiceBus in .NET 6.
I want to preserve ordering (FIFO) when reading so I only use 1 ServiceBusReceiver.
I have done tests both with receiving one message at a time (ReceiveMessageAsync and then CompleteMessageAsync) and receiving batches (ReceiveMessagesAsync(x) followed by a loop with CompleteMessageAsync).

My tests shows that I only process around 5-10 msg/sec which seems very low.
If I comment out the CompleteMessageAsync statement the performance is a lot better. For example, when using a batch size of 10 the throughput is a bit over 100 msg/sec.

This tells me the bottleneck is in the CompleteMessageAsync method.

Can I do something about this and still maintain FIFO? A throughput of 5-10 msg/sec is way to low.

Regards
Steve

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
542 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. File 1 Reputation point
    2022-05-12T18:06:47.42+00:00

    I'm having similar issues regarding the performance. Have tested with both Standard and Premium-tier of Service Bus and Standard, weirdly enough, perform better (faster) than Standard in many cases.

    Are you using Standard or Premium? Anyone else experiencing the same problems and maybe have a solution?


  2. MughundhanRaveendran-MSFT 12,421 Reputation points
    2022-05-18T10:16:07.75+00:00

    Hi @Stefan ,

    Thanks for reaching out to Q&A.

    Concurrency would definitely help in improving the performance and throughput however you would like to have only one receiver. I would suggest you to make use of the prefetch feature in service bus. Prefetch speeds up the message flow by having a message readily available for local retrieval before the application asks for one. When you enable the Prefetch feature for any of the official Service Bus clients, the receiver acquires more messages than what the application initially asked for, up to the specified prefetch count.

    Please note that, prefetch is not enabled by default. To enable the Prefetch feature, set the prefetch count of the queue or subscription client to a number greater than zero. Setting the value to zero turns off prefetch. Please try this and let me know if the throughput is increased.

    I hope this helps! Feel free to reach out to me if you have any queries or concerns.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.