Current setup
- 20+ publishers & subscribers with 5 running instances each
- One MsSQL db with all messaging tables required for all publishers and subscribers
NServiceBus packages:
- NServiceBus 7.4.4
- NServiceBus.Extensions.DependencyInjection 1.0.1
- NServiceBus.Newtonsoft.Json 2.2.0
- NServiceBus.Persistence.Sql 6.2.0 (upgraded from 6.0.4)
- NServiceBus.Transport.SqlServer 6.2.0 (upgraded to from 6.0.1)
Enpoint configuration
// Notes
// concurrencyLimit varies from component to component but its usually 8 or around
endpointConfiguration.DisableFeature();
endpointConfiguration.PurgeOnStartup(false);
endpointConfiguration.UseContainer(container);
endpointConfiguration.OverrideLocalAddress(endpointAddress);
endpointConfiguration.SendFailedMessagesTo(endpointErrorAddress);
var persistence = endpointConfiguration.UsePersistence();
persistence.SqlDialect<SqlDialect.MsSqlServer>();
persistence.ConnectionBuilder(() => new SqlConnection(connectionString));
persistence.SubscriptionSettings().CacheFor(TimeSpan.FromHours(1));
persistence.TablePrefix(tablePrefix);
var transport = endpointConfiguration.UseTransport();
transport.QueuePeekerOptions(null, concurrencyLimit * 2);
// transport.QueuePeekerOptions(TimeSpan.FromSeconds(5), concurrencyLimit * 2);
transport.Transactions(TransportTransactionMode.TransactionScope);
transport.ConnectionString(connectionString);
transport.Routing();
endpointConfiguration.LimitMessageProcessingConcurrencyTo(concurrencyLimit);
endpointConfiguration.DefineCriticalErrorAction(OnCriticalError);
endpointConfiguration.Pipeline.Register(loggingRelatedPipeline);
var recoverability = endpointConfiguration.Recoverability();
recoverability.CustomPolicy(customPolicy); //just checking the exception type and decide retry behavior based on that
Behaviour after upgrade
Db server batch requests per second jump up to almost ten times than before causing high cpu usage and general performance degradation.
Changing the queue peeker durations to 5 seconds improves things somewhat by not having constantly the high batch request per second but spikes still happen at short intervals.
The same behavior is observed with any version greater than NServiceBus.Transport.SqlServer 6.0.1 from 6.1.1 not just 6.2.0
The same behavior is observed with or without upgrading NServiceBus.Persistence.Sql from 6.0.4 to 6.2.0
Are there any other things that need to be configured that we missed?