I'm unfortunately experiencing very low throughput with on-premise version of Service Bus periodically.
Normally sending a message takes about 10 ms or less, however quite frequently it can take 20 seconds or more to send a message. This continues for 2 - 3 minutes and after a while the messages either timeout or there is a spike where Service Bus manages to process all messages. This can be seen by viewing the Incomming messages performance counter below.
The system is running Service Bus 1.1 with SQL Server 2012 on a separate machine. The hardware is Intel Q6600 2.40GHz, 4GB ram and 7200rpm disks so it is normally OK for most testing purposes.
I have isolated some code from my application that reproduces the issue.
static void Main(string[] args) { var connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"]; var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); namespaceManager.DeleteTopic("TestTopic"); namespaceManager.CreateTopic("TestTopic"); namespaceManager.CreateSubscription("TestTopic", "TestSubScription"); var topicClient = TopicClient.CreateFromConnectionString(connectionString, "TestTopic"); var msgCounter = 0; var cts = new CancellationTokenSource(); Task.Run(() => { while (!cts.IsCancellationRequested) { Task.Run(() => { try { Interlocked.Increment(ref msgCounter); var msg = new BrokeredMessage("Body"); msg.Properties["MyIntProperty"] = 123; msg.Properties["MyStringProperty"] = "Hello SB"; var sw = Stopwatch.StartNew(); topicClient.Send(msg); sw.Stop(); Trace.WriteLine(string.Format("Message {0} send duration {1}", msgCounter, sw.ElapsedMilliseconds)); } catch (Exception e) { Trace.WriteLine("Exception: " + e); } }, cts.Token); Thread.Sleep(20); } }, cts.Token); Console.ReadLine(); cts.Cancel(); }
As can be seen this is a very low message frequency of about 30 messages / sec so I don't understand how Service Bus can struggle with this low throughput. Event when I increased the delay to 50 ms the issue still occurred.
Hoping someone can shed some light on this, or provide insights on how to continue troubleshooting.