Update POOL di RIOC x testing specifico sotto carico

This commit is contained in:
Samuele Locatelli
2026-06-12 17:58:10 +02:00
parent 12994c5c7a
commit 5e7016629a
7 changed files with 38 additions and 7 deletions
+24 -3
View File
@@ -12,8 +12,17 @@ using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// recupero env corrente
// RECUPERO L'AMBIENTE REALE (Che ora IIS passa correttamente come 'Staging')
var env = builder.Environment;
// FORZA IL CARICAMENTO CORRETTO DEI JSON CON LA GERARCHIA DI AMBIENTE
builder.Configuration
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables();
// recupero env corrente
var logger = LogManager.Setup()
.LoadConfigurationFromAppSettings()
.GetCurrentClassLogger();
@@ -60,23 +69,35 @@ builder.Services.AddDbContextFactory<MoonPro_UtilsContext>(options =>
builder.Services.AddIocDataLayer();
// 1. Configurazione dell'invoker personalizzato (Risolve i tuoi errori)
// 1. Configurazione dell'invoker personalizzato (Potenziato con il Pooling)
var httpClientInvoker = new HttpMessageInvoker(new SocketsHttpHandler
{
UseProxy = false,
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
// Correzione per il tracing: usa il propagatore corrente di sistema
ActivityHeadersPropagator = DistributedContextPropagator.Current,
ConnectTimeout = TimeSpan.FromSeconds(60),
// Gestione certificato (ignora errori per localhost/test)
// ==================================================================
// 🚀 LE TRE RIGHE PER ABBATTERE IL MURO DEI 2 SECONDI SOTTO STRESS
// ==================================================================
// Permette a YARP di aprire fino a 5000 canali paralleli contemporanei verso IIS
MaxConnectionsPerServer = 5000,
// Tiene caldi i socket ed evita di rifare l'handshake TCP/TLS a ogni richiesta
PooledConnectionLifetime = TimeSpan.FromMinutes(15),
PooledConnectionIdleTimeout = TimeSpan.FromMinutes(2),
// ==================================================================
// Gestione certificato (Invariata)
SslOptions = new System.Net.Security.SslClientAuthenticationOptions
{
RemoteCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
}
});
// Registrazione nella Dependency Injection (Invariata)
builder.Services.AddSingleton(httpClientInvoker);
builder.Services.AddHttpForwarder();