question

Stefan-1807 avatar image
0 Votes"
Stefan-1807 asked Stefan-1807 commented

Azure Service Bus - Completemessageasync running slow

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

file01 avatar image
0 Votes"
file01 answered Stefan-1807 commented

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?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for commenting @file01 .
Yes, I have also tested with both standard and premium-tier to be sure that I don´t get way better figures with premium, however standard was at least as performant as premium (same as you have experienced).

Hope someone has a solution on this.

0 Votes 0 ·
MughundhanRaveendran-MSFT avatar image
0 Votes"
MughundhanRaveendran-MSFT answered Stefan-1807 commented

Hi @Stefan-1807 ,

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.




· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your comment @MughundhanRaveendran-MSFT .
Prefetch would propably give a boost to the performance of the receive operation. However the poor performance is related to the Complete operation.

Regards
Steve

0 Votes 0 ·