Startup.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using Serilog;
  2. namespace Aip.Service;
  3. public class Startup
  4. {
  5. public static void SetSystemConfig()
  6. {
  7. ThreadPool.GetAvailableThreads(out int workerThreads1, out int completionPortThreads1);
  8. ThreadPool.GetMaxThreads(out int workerThreads2, out int completionPortThreads2);
  9. ThreadPool.GetMinThreads(out int workerThreads3, out int completionPortThreads3);
  10. Log.Information(" AvailableThreads: worker({0}), port({1})", workerThreads1, completionPortThreads1);
  11. Log.Information(" MaxThreads: worker({0}), port({1})", workerThreads2, completionPortThreads2);
  12. Log.Information(" MinThreads: worker({0}), port({1})", workerThreads3, completionPortThreads3);
  13. Log.Information(" UseNagleAlgorithm: {0}", System.Net.ServicePointManager.UseNagleAlgorithm);
  14. System.Net.ServicePointManager.UseNagleAlgorithm = false;
  15. Log.Information(" UseNagleAlgorithm: {0}, Application Set.", System.Net.ServicePointManager.UseNagleAlgorithm);
  16. Log.Information(" Expect100Continue: {0}", System.Net.ServicePointManager.Expect100Continue);
  17. System.Net.ServicePointManager.Expect100Continue = false;
  18. Log.Information(" Expect100Continue: {0}, Application Set.", System.Net.ServicePointManager.Expect100Continue);
  19. Log.Information(" CheckCertificateRevocationList: {0}", System.Net.ServicePointManager.CheckCertificateRevocationList);
  20. System.Net.ServicePointManager.CheckCertificateRevocationList = true;
  21. Log.Information(" CheckCertificateRevocationList: {0}, Application Set.", System.Net.ServicePointManager.CheckCertificateRevocationList);
  22. Log.Information("DefaultPersistentConnectionLimit: {0}", System.Net.ServicePointManager.DefaultPersistentConnectionLimit);
  23. Log.Information(" DefaultConnectionLimit: {0}", System.Net.ServicePointManager.DefaultConnectionLimit);
  24. System.Net.ServicePointManager.DefaultConnectionLimit = 2048;
  25. Log.Information(" DefaultConnectionLimit: {0}, Application Set.", System.Net.ServicePointManager.DefaultConnectionLimit);
  26. // Bump up the min threads reserved for this app to ramp connections faster - minWorkerThreads defaults to 4, minIOCP defaults to 4
  27. ThreadPool.SetMinThreads(100, 100);
  28. // Change max connections from .NET to a remote service default: 2
  29. //System.Net.ServicePointManager.DefaultConnectionLimit = 65000;
  30. // 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
  31. //System.Net.ServicePointManager.Expect100Continue = false;
  32. // Can decrease overall transmission overhead but can cause delay in data packet arrival
  33. //System.Net.ServicePointManager.UseNagleAlgorithm = false;
  34. }
  35. }