From 1e98cf20dd9787c1d47676753bdb000886c6ec7a Mon Sep 17 00:00:00 2001 From: danielmarbach Date: Tue, 19 Mar 2024 08:48:16 +0100 Subject: [PATCH 1/2] Remove ServicePointManager usage from acceptance tests since generally .NET is moving away from ServicePointManager --- .../EndpointTemplates/DefaultServerBase.cs | 3 --- .../TestSupport/AcceptanceTest.cs | 11 ----------- .../AcceptanceTest.cs | 10 ---------- .../AcceptanceTest.cs | 11 ----------- .../AcceptanceTest.cs | 10 ---------- 5 files changed, 45 deletions(-) diff --git a/src/ServiceControl.AcceptanceTesting/EndpointTemplates/DefaultServerBase.cs b/src/ServiceControl.AcceptanceTesting/EndpointTemplates/DefaultServerBase.cs index fed815ee6e..ebce313153 100644 --- a/src/ServiceControl.AcceptanceTesting/EndpointTemplates/DefaultServerBase.cs +++ b/src/ServiceControl.AcceptanceTesting/EndpointTemplates/DefaultServerBase.cs @@ -1,7 +1,6 @@ namespace ServiceControl.AcceptanceTesting.EndpointTemplates { using System; - using System.Net; using System.Threading.Tasks; using AcceptanceTesting; using NServiceBus; @@ -19,8 +18,6 @@ protected DefaultServerBase() : this(new ConfigureEndpointLearningTransport()) public virtual async Task GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizations, Func configurationBuilderCustomization) { - ServicePointManager.DefaultConnectionLimit = 100; - var endpointConfiguration = new EndpointConfiguration(endpointCustomizations.EndpointName); endpointConfiguration.Pipeline.Register(new StampDispatchBehavior(runDescriptor.ScenarioContext), "Stamps outgoing messages with session ID"); diff --git a/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs b/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs index bcb3af7ca6..9c55e0f276 100644 --- a/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs +++ b/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs @@ -3,7 +3,6 @@ namespace ServiceControl.AcceptanceTests using System; using System.Diagnostics; using System.IO; - using System.Net; using System.Net.Http; using System.Text.Json; using System.Threading; @@ -20,18 +19,8 @@ namespace ServiceControl.AcceptanceTests using TestSupport; [TestFixture] - //[Parallelizable(ParallelScope.All)] abstract class AcceptanceTest : NServiceBusAcceptanceTest, IAcceptanceTestInfrastructureProvider { - protected AcceptanceTest() - { - ServicePointManager.DefaultConnectionLimit = int.MaxValue; - ServicePointManager.MaxServicePoints = int.MaxValue; - ServicePointManager.UseNagleAlgorithm = false; // Improvement for small tcp packets traffic, get buffered up to 1/2-second. If your storage communication is for small (less than ~1400 byte) payloads, this setting should help (especially when dealing with things like Azure Queues, which tend to have very small messages). - ServicePointManager.Expect100Continue = false; // This ensures tcp ports are free up quicker by the OS, prevents starvation of ports - ServicePointManager.SetTcpKeepAlive(true, 5000, 1000); // This is good for Azure because it reuses connections - } - public IDomainEvents DomainEvents => serviceControlRunnerBehavior.DomainEvents; public HttpClient HttpClient => serviceControlRunnerBehavior.HttpClient; public JsonSerializerOptions SerializerOptions => serviceControlRunnerBehavior.SerializerOptions; diff --git a/src/ServiceControl.Audit.AcceptanceTests/AcceptanceTest.cs b/src/ServiceControl.Audit.AcceptanceTests/AcceptanceTest.cs index a7033e35bf..13365451df 100644 --- a/src/ServiceControl.Audit.AcceptanceTests/AcceptanceTest.cs +++ b/src/ServiceControl.Audit.AcceptanceTests/AcceptanceTest.cs @@ -4,7 +4,6 @@ namespace ServiceControl.Audit.AcceptanceTests using System.Collections.Generic; using System.Diagnostics; using System.IO; - using System.Net; using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; @@ -21,15 +20,6 @@ namespace ServiceControl.Audit.AcceptanceTests [TestFixture] abstract class AcceptanceTest : NServiceBusAcceptanceTest, IAcceptanceTestInfrastructureProvider { - protected AcceptanceTest() - { - ServicePointManager.DefaultConnectionLimit = int.MaxValue; - ServicePointManager.MaxServicePoints = int.MaxValue; - ServicePointManager.UseNagleAlgorithm = false; // Improvement for small tcp packets traffic, get buffered up to 1/2-second. If your storage communication is for small (less than ~1400 byte) payloads, this setting should help (especially when dealing with things like Azure Queues, which tend to have very small messages). - ServicePointManager.Expect100Continue = false; // This ensures tcp ports are free up quicker by the OS, prevents starvation of ports - ServicePointManager.SetTcpKeepAlive(true, 5000, 1000); // This is good for Azure because it reuses connections - } - public HttpClient HttpClient => serviceControlRunnerBehavior.HttpClient; public JsonSerializerOptions SerializerOptions => serviceControlRunnerBehavior.SerializerOptions; protected IServiceProvider ServiceProvider => serviceControlRunnerBehavior.ServiceProvider; diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/AcceptanceTest.cs b/src/ServiceControl.Monitoring.AcceptanceTests/AcceptanceTest.cs index beff1f693f..aaf1849fd2 100644 --- a/src/ServiceControl.Monitoring.AcceptanceTests/AcceptanceTest.cs +++ b/src/ServiceControl.Monitoring.AcceptanceTests/AcceptanceTest.cs @@ -3,7 +3,6 @@ namespace ServiceControl.Monitoring.AcceptanceTests using System; using System.Diagnostics; using System.IO; - using System.Net; using System.Net.Http; using System.Text.Json; using AcceptanceTesting; @@ -18,16 +17,6 @@ namespace ServiceControl.Monitoring.AcceptanceTests [TestFixture] abstract class AcceptanceTest : NServiceBusAcceptanceTest, IAcceptanceTestInfrastructureProvider { - protected AcceptanceTest() - { - ServicePointManager.DefaultConnectionLimit = int.MaxValue; - ServicePointManager.MaxServicePoints = int.MaxValue; - ServicePointManager.UseNagleAlgorithm = false; // Improvement for small tcp packets traffic, get buffered up to 1/2-second. If your storage communication is for small (less than ~1400 byte) payloads, this setting should help (especially when dealing with things like Azure Queues, which tend to have very small messages). - ServicePointManager.Expect100Continue = false; // This ensures tcp ports are free up quicker by the OS, prevents starvation of ports - ServicePointManager.SetTcpKeepAlive(true, 5000, 1000); // This is good for Azure because it reuses connections - } - - public HttpClient HttpClient => serviceControlRunnerBehavior.HttpClient; public JsonSerializerOptions SerializerOptions => serviceControlRunnerBehavior.SerializerOptions; diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs index e7b89cf80f..0c3cf0fde7 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs @@ -4,7 +4,6 @@ namespace ServiceControl.MultiInstance.AcceptanceTests using System.Collections.Generic; using System.Diagnostics; using System.IO; - using System.Net; using System.Net.Http; using System.Text.Json; using AcceptanceTesting; @@ -20,15 +19,6 @@ namespace ServiceControl.MultiInstance.AcceptanceTests [TestFixture] abstract class AcceptanceTest : NServiceBusAcceptanceTest, IAcceptanceTestInfrastructureProviderMultiInstance { - protected AcceptanceTest() - { - ServicePointManager.DefaultConnectionLimit = int.MaxValue; - ServicePointManager.MaxServicePoints = int.MaxValue; - ServicePointManager.UseNagleAlgorithm = false; // Improvement for small tcp packets traffic, get buffered up to 1/2-second. If your storage communication is for small (less than ~1400 byte) payloads, this setting should help (especially when dealing with things like Azure Queues, which tend to have very small messages). - ServicePointManager.Expect100Continue = false; // This ensures tcp ports are free up quicker by the OS, prevents starvation of ports - ServicePointManager.SetTcpKeepAlive(true, 5000, 1000); // This is good for Azure because it reuses connections - } - protected static string ServiceControlInstanceName { get; } = Settings.DEFAULT_SERVICE_NAME; protected static string ServiceControlAuditInstanceName { get; } = Audit.Infrastructure.Settings.Settings.DEFAULT_SERVICE_NAME; From 5398b1471ac7de6b0ef19d48b80a0fb0f4cb08c9 Mon Sep 17 00:00:00 2001 From: danielmarbach Date: Tue, 19 Mar 2024 17:51:06 +0100 Subject: [PATCH 2/2] Remove HttpDefaultConnectionLimit since the setting doesn't make sense anymore with modern HTTP Client usage. We have decided against adding a log warning since generally it is OK to have settings in app.config that are no longer relevant. --- .../TestSupport/ServiceControlComponentRunner.cs | 1 - .../TestSupport/ServiceControlComponentRunner.cs | 1 - .../APIApprovals.PlatformSampleSettings.approved.txt | 1 - src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs | 3 --- src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs | 2 -- .../Infrastructure/WebApi/RootController.cs | 1 - .../APIApprovals.PlatformSampleSettings.approved.txt | 1 - src/ServiceControl/HostApplicationBuilderExtensions.cs | 3 --- src/ServiceControl/Infrastructure/Settings/Settings.cs | 2 -- src/ServiceControl/Infrastructure/WebApi/RootController.cs | 1 - 10 files changed, 16 deletions(-) diff --git a/src/ServiceControl.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs b/src/ServiceControl.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs index 0291efbfd0..f74b6e12e5 100644 --- a/src/ServiceControl.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs +++ b/src/ServiceControl.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs @@ -53,7 +53,6 @@ async Task InitializeServiceControl(ScenarioContext context) ProcessRetryBatchesFrequency = TimeSpan.FromSeconds(2), TimeToRestartErrorIngestionAfterFailure = TimeSpan.FromSeconds(2), MaximumConcurrencyLevel = 2, - HttpDefaultConnectionLimit = int.MaxValue, DisableHealthChecks = true, MessageFilter = messageContext => { diff --git a/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs b/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs index 453754ec52..7b4c6a0af8 100644 --- a/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs +++ b/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs @@ -42,7 +42,6 @@ async Task InitializeServiceControl(ScenarioContext context) { TransportConnectionString = transportToUse.ConnectionString, MaximumConcurrencyLevel = 2, - HttpDefaultConnectionLimit = int.MaxValue, ServiceControlQueueAddress = "SHOULDNOTBEUSED", MessageFilter = messageContext => { diff --git a/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt b/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt index c1746946e1..5739f5dc9d 100644 --- a/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt +++ b/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt @@ -18,7 +18,6 @@ "AuditRetentionPeriod": "30.00:00:00", "MaxBodySizeToStore": 102400, "ServiceName": "Particular.ServiceControl.Audit", - "HttpDefaultConnectionLimit": 100, "TransportConnectionString": null, "MaximumConcurrencyLevel": 32, "DataSpaceRemainingThreshold": 20, diff --git a/src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs b/src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs index 1ef961ff4b..ca01e8368d 100644 --- a/src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs +++ b/src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs @@ -41,9 +41,6 @@ static class HostApplicationBuilderExtensions configuration.License(settings.LicenseFileText); } - // .NET default limit is 10. RavenDB in conjunction with transports that use HTTP exceeds that limit. - ServicePointManager.DefaultConnectionLimit = settings.HttpDefaultConnectionLimit; - var transportSettings = MapSettings(settings); var transportCustomization = settings.LoadTransportCustomization(); diff --git a/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs b/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs index 32589210b0..9cffda9c3e 100644 --- a/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs +++ b/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs @@ -35,7 +35,6 @@ public Settings(string serviceName, string transportType = null, string persiste AuditRetentionPeriod = GetAuditRetentionPeriod(); Port = SettingsReader.Read(SettingsRootNamespace, "Port", 44444); MaximumConcurrencyLevel = SettingsReader.Read(SettingsRootNamespace, "MaximumConcurrencyLevel", 32); - HttpDefaultConnectionLimit = SettingsReader.Read(SettingsRootNamespace, "HttpDefaultConnectionLimit", 100); DataSpaceRemainingThreshold = GetDataSpaceRemainingThreshold(); ServiceControlQueueAddress = SettingsReader.Read(SettingsRootNamespace, "ServiceControlQueueAddress"); TimeToRestartAuditIngestionAfterFailure = GetTimeToRestartAuditIngestionAfterFailure(); @@ -131,7 +130,6 @@ public int MaxBodySizeToStore public string ServiceName { get; } - public int HttpDefaultConnectionLimit { get; set; } public string TransportConnectionString { get; set; } public int MaximumConcurrencyLevel { get; set; } public int DataSpaceRemainingThreshold { get; set; } diff --git a/src/ServiceControl.Audit/Infrastructure/WebApi/RootController.cs b/src/ServiceControl.Audit/Infrastructure/WebApi/RootController.cs index 851681a866..770711b1e2 100644 --- a/src/ServiceControl.Audit/Infrastructure/WebApi/RootController.cs +++ b/src/ServiceControl.Audit/Infrastructure/WebApi/RootController.cs @@ -63,7 +63,6 @@ public OkObjectResult Config() PerformanceTunning = new { settings.MaxBodySizeToStore, - settings.HttpDefaultConnectionLimit, }, Transport = new { diff --git a/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt b/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt index 37eaab348a..a345c39fa4 100644 --- a/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt +++ b/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt @@ -30,7 +30,6 @@ "ErrorRetentionPeriod": "10.00:00:00", "EventsRetentionPeriod": "14.00:00:00", "ServiceName": "Particular.ServiceControl", - "HttpDefaultConnectionLimit": 100, "TransportConnectionString": null, "ProcessRetryBatchesFrequency": "00:00:30", "TimeToRestartErrorIngestionAfterFailure": "00:01:00", diff --git a/src/ServiceControl/HostApplicationBuilderExtensions.cs b/src/ServiceControl/HostApplicationBuilderExtensions.cs index 5ec157a675..7cba64fd35 100644 --- a/src/ServiceControl/HostApplicationBuilderExtensions.cs +++ b/src/ServiceControl/HostApplicationBuilderExtensions.cs @@ -48,9 +48,6 @@ public static void AddServiceControl(this IHostApplicationBuilder hostBuilder, S EventSourceCreator.Create(); } - // .NET default limit is 10. RavenDB in conjunction with transports that use HTTP exceeds that limit. - ServicePointManager.DefaultConnectionLimit = settings.HttpDefaultConnectionLimit; - var transportCustomization = settings.LoadTransportCustomization(); var transportSettings = MapSettings(settings); diff --git a/src/ServiceControl/Infrastructure/Settings/Settings.cs b/src/ServiceControl/Infrastructure/Settings/Settings.cs index a8deab25fd..adb3442378 100644 --- a/src/ServiceControl/Infrastructure/Settings/Settings.cs +++ b/src/ServiceControl/Infrastructure/Settings/Settings.cs @@ -49,7 +49,6 @@ public class Settings ProcessRetryBatchesFrequency = TimeSpan.FromSeconds(30); MaximumConcurrencyLevel = SettingsReader.Read(SettingsRootNamespace, "MaximumConcurrencyLevel", 10); RetryHistoryDepth = SettingsReader.Read(SettingsRootNamespace, "RetryHistoryDepth", 10); - HttpDefaultConnectionLimit = SettingsReader.Read(SettingsRootNamespace, "HttpDefaultConnectionLimit", 100); AllowMessageEditing = SettingsReader.Read(SettingsRootNamespace, "AllowMessageEditing"); NotificationsFilter = SettingsReader.Read(SettingsRootNamespace, "NotificationsFilter"); RemoteInstances = GetRemoteInstances().ToArray(); @@ -156,7 +155,6 @@ public TimeSpan HeartbeatGracePeriod public TimeSpan EventsRetentionPeriod { get; } public string ServiceName { get; } - public int HttpDefaultConnectionLimit { get; set; } public string TransportConnectionString { get; set; } public TimeSpan ProcessRetryBatchesFrequency { get; set; } public TimeSpan TimeToRestartErrorIngestionAfterFailure { get; set; } diff --git a/src/ServiceControl/Infrastructure/WebApi/RootController.cs b/src/ServiceControl/Infrastructure/WebApi/RootController.cs index a2b0b5aced..137b65089e 100644 --- a/src/ServiceControl/Infrastructure/WebApi/RootController.cs +++ b/src/ServiceControl/Infrastructure/WebApi/RootController.cs @@ -78,7 +78,6 @@ public object Config() }, PerformanceTunning = new { - settings.HttpDefaultConnectionLimit, settings.ExternalIntegrationsDispatchingBatchSize }, PersistenceSettings = settings.PersisterSpecificSettings,