using Serilog; namespace AipGateway.AIP.Service { public class Startup { public static void SetSystemConfig() { ThreadPool.GetAvailableThreads(out int workerThreads1, out int completionPortThreads1); ThreadPool.GetMaxThreads(out int workerThreads2, out int completionPortThreads2); ThreadPool.GetMinThreads(out int workerThreads3, out int completionPortThreads3); Log.Information(" AvailableThreads: worker({0}), port({1})", workerThreads1, completionPortThreads1); Log.Information(" MaxThreads: worker({0}), port({1})", workerThreads2, completionPortThreads2); Log.Information(" MinThreads: worker({0}), port({1})", workerThreads3, completionPortThreads3); Log.Information(" UseNagleAlgorithm: {0}", System.Net.ServicePointManager.UseNagleAlgorithm); System.Net.ServicePointManager.UseNagleAlgorithm = false; Log.Information(" UseNagleAlgorithm: {0}, Application Set.", System.Net.ServicePointManager.UseNagleAlgorithm); Log.Information(" Expect100Continue: {0}", System.Net.ServicePointManager.Expect100Continue); System.Net.ServicePointManager.Expect100Continue = false; Log.Information(" Expect100Continue: {0}, Application Set.", System.Net.ServicePointManager.Expect100Continue); Log.Information(" CheckCertificateRevocationList: {0}", System.Net.ServicePointManager.CheckCertificateRevocationList); System.Net.ServicePointManager.CheckCertificateRevocationList = true; Log.Information(" CheckCertificateRevocationList: {0}, Application Set.", System.Net.ServicePointManager.CheckCertificateRevocationList); Log.Information("DefaultPersistentConnectionLimit: {0}", System.Net.ServicePointManager.DefaultPersistentConnectionLimit); Log.Information(" DefaultConnectionLimit: {0}", System.Net.ServicePointManager.DefaultConnectionLimit); System.Net.ServicePointManager.DefaultConnectionLimit = 2048; Log.Information(" DefaultConnectionLimit: {0}, Application Set.", System.Net.ServicePointManager.DefaultConnectionLimit); // Bump up the min threads reserved for this app to ramp connections faster - minWorkerThreads defaults to 4, minIOCP defaults to 4 ThreadPool.SetMinThreads(100, 100); // Change max connections from .NET to a remote service default: 2 //System.Net.ServicePointManager.DefaultConnectionLimit = 65000; // Turn off the Expect 100 to continue message - 'true' will cause the caller to wait until it round-trip confirms a connection to the server //System.Net.ServicePointManager.Expect100Continue = false; // Can decrease overall transmission overhead but can cause delay in data packet arrival //System.Net.ServicePointManager.UseNagleAlgorithm = false; } public static bool AipFileInitialize(AipFileManager aipFileManager) { if (!aipFileManager.Initialize()) { Log.Error("AipFileInitialize, aipFileManager.Initialize Failed, {0}, {1}", aipFileManager.LastErrNo, aipFileManager.LastErrMsg); return false; } if (!aipFileManager.CreateProfile()) { Log.Error("AipFileInitialize, aipFileManager.CreateProfile Failed, {0}, {1}", aipFileManager.LastErrNo, aipFileManager.LastErrMsg); return false; } if (!aipFileManager.CreateEngine()) { Log.Error("AipFileInitialize, aipFileManager.CreateEngine Failed, {0}, {1}", aipFileManager.LastErrNo, aipFileManager.LastErrMsg); return false; } return true; } } }