Read my blog here
Last active
July 6, 2020 13:19
-
-
Save jstemerdink/52616c936014564071396a1a0a59be5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Global : EPiServer.Global | |
{ | |
protected void Application_Start() | |
{ | |
// Other stuff here | |
// See: https://support.microsoft.com/en-gb/help/821268/contention-poor-performance-and-deadlocks-when-you-make-calls-to-web-s | |
// See: https://docs.microsoft.com/en-us/azure/redis-cache/cache-faq | |
SetMinThreads(); | |
SetMaxThreads(); | |
} | |
private static void SetMinThreads() | |
{ | |
int workerThreads = string.IsNullOrEmpty(ConfigurationManager.AppSettings["WORKER_THREADS"]) | |
? 50 | |
: Convert.ToInt32(ConfigurationManager.AppSettings["WORKER_THREADS"]); | |
int iocpThreads = string.IsNullOrEmpty(ConfigurationManager.AppSettings["IOCP_THREADS"]) | |
? 50 | |
: Convert.ToInt32(ConfigurationManager.AppSettings["IOCP_THREADS"]); | |
ThreadPool.SetMinThreads(workerThreads, iocpThreads); | |
} | |
private static void SetMaxThreads() | |
{ | |
int workerThreads = string.IsNullOrEmpty(ConfigurationManager.AppSettings["MAX_WORKER_THREADS"]) | |
? 100 | |
: Convert.ToInt32(ConfigurationManager.AppSettings["MAX_WORKER_THREADS"]); | |
int iocpThreads = string.IsNullOrEmpty(ConfigurationManager.AppSettings["MAX_IOCP_THREADS"]) | |
? 100 | |
: Convert.ToInt32(ConfigurationManager.AppSettings["MAX_IOCP_THREADS"]); | |
ThreadPool.SetMaxThreads(workerThreads, iocpThreads); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<appSettings> | |
<add key="WORKER_THREADS" value="50" /> | |
<add key="IOCP_THREADS" value="50" /> | |
<add key="MAX_WORKER_THREADS" value="100" /> | |
<add key="MAX_IOCP_THREADS" value="100" /> | |
</appSettings> | |
<system.web> | |
<httpRuntime targetFramework="4.6.1" requestValidationMode="2.0" maxRequestLength="1048576" executionTimeout="900" minFreeThreads="352" minLocalRequestFreeThreads="304"/> | |
</system.web> | |
<system.net> | |
<connectionManagement> | |
<add address="*" maxconnection="48" /> | |
</connectionManagement> | |
</system.net> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment