0

First of all, excuse my English, it's very bad. I am using MassTransit with Azure Service Bus for asynchronous communication between microservices. I have some doubts about the default configuration of masstransit together with azure service bus, but I have not been able to clarify them in the documentation. These doubts are the following:

  • Is there a way to set a default TTL for all queues and topics? And a size for the queues and topics? The documentation specifies that the TTL and the size of the queues can be adjusted when the receiver is connected / created, but on the other hand, regarding the topics, it is specified how to adjust the TTL if the consumer connects to a specific topic, however in this case our consumers do not subscribe to a specific topic, but simply to a messageType, and Masstransit does the rest (creates the topic, the subscriber and forwards the message from the subscriber to the consumer's queue).

  • On the other hand, what are the default values of PrefetchCount and MaxConcurrentCalls? And some optimal values to obtain the highest performance considering that consumers have horizontal scaling (competing consumer)? From what I have read in other questions, the PrefetchCount and MaxConcurrentCalls values must be close to each other to optimize performance, is that correct?

Thank you very much.

Regards

1 Answers1

1

The defaults for all Azure Service Bus entities are in this file and can be adjusted prior to bus creation.

The defaults include (edited):

namespace MassTransit.Azure.ServiceBus.Core
{
    public static class Defaults
    {
        public static TimeSpan LockDuration = TimeSpan.FromMinutes(5);
        public static TimeSpan DefaultMessageTimeToLive = TimeSpan.FromDays(365 + 1);
        public static TimeSpan BasicMessageTimeToLive = TimeSpan.FromDays(14);

        public static TimeSpan AutoDeleteOnIdle => TimeSpan.FromDays(427);
        public static TimeSpan TemporaryAutoDeleteOnIdle => TimeSpan.FromMinutes(5);
        public static TimeSpan MaxAutoRenewDuration => TimeSpan.FromMinutes(5);
        public static TimeSpan MessageWaitTimeout => TimeSpan.FromSeconds(10);
        public static TimeSpan ShutdownTimeout { get; set; } = TimeSpan.FromMilliseconds(100);

        public static int MaxConcurrentCalls => Math.Max(Environment.ProcessorCount, 8);
        public static int PrefetchCount => Math.Max(MaxConcurrentCalls, 32);
    }
}

As for optimizing the PrefetchCount/MaxConcurrentCalls settings, they should typically be matched for competing consumer with multiple instances to distribute the load.

Chris Patterson
  • 28,659
  • 3
  • 47
  • 59
  • Thanks Chris, this is very useful. On the other hand, I ask you some more questions: what is the difference between "BasicMessageTimeToLive" and "DefaultMessageTimeToLive"? How can the TTL of a subscription be set? Can I set different default values for each queue / topic / subscription? Regards – Borja Fernández Mar 23 '21 at 09:16
  • any idea? Thanks! – Borja Fernández Mar 31 '21 at 16:36
  • `BasicMessageTimeToLive` is for the basic tier of ASB, it's also used for dead-letter message timeout (strangely). I'm not sure if Subscription TimeToLive is configurable for a subscription endpoint. Since MassTransit uses forwarding subscriptions, the TTL value isn't actually respected by ASB. – Chris Patterson Mar 31 '21 at 19:14