19. • ASP.NET
• CLR Performance Counters
Discover. Master. Influence.
20. 24Discover. Master. Influence.
• ASP.NET Performance Counters (IIS 6.0 or II7.0
classic mode)
Client
IIS App Domain
App Domain QueueNamed Pipe
Requests
waiting to be
written to
client
WebServiceISAPI
Extension ReqSec
ASP.NET
Rejected
Requests
ASP.NET
Requests
Wait Time
ASP.NET
Requests
Queued
ASP.NET Requests in
Application Queue
ASP.NET
Application
Requests
Executing
ASP.NET Worker Process
Restarts
ASP.NET
ApplicationsRequest
Sec
Pipeline
ASP.NET Worker Process
23. • IIS App pool
– Queue Length (1000 by default)
– Idle timeout (default is 20)
• Aspnet_config or (registry)
– maxConcurrentRequestsPerCPU
– in v4.0 is 5000 (default)
• ServicePointManager.DefaultConnectionLimit
• Max ADO.NET connection Pool Size (default is 100)
• Machine.config
– Processmodel.Autoconfig (turned on by default)
28Discover. Master. Influence.
24. • Performance counters
• Visual Studio Load test
• Visual studio profiler
(CPU/Memory/Concurrency
measurements)
• 3rd Party tools like Red gate’s ANTS profiler
• Apache Benchmark
29Discover. Master. Influence.
25. • Transfer less data and make use of caching
• Use efficient mime types for internal
application
• Don’t block your thread pool threads
• Measure your throughput by tests
• Tweak IIS settings when needed
• Don’t run your test on Client OS
30Discover. Master. Influence.
Start with blocking sampleStep 1 shows use of task.createnew – explain the concept of blocking threadpool threadStep 2 shows use of async keyword
//convert this slide to animation to explain the concept of threadsstatic void SyncMain(string[] args) { ...while (true) { varclient = socket.AcceptTcpClient(); ...vart1 = new Thread(new ThreadStart(() => ...ServiceClient(client);In the main loop we accept new clients (AcceptTcpClient), and for each one we start a new thread (ThreadStart) that calls ServiceClient(), which is this little function that is a lot like the pseudocode I mentioned earlier:static void ServiceClient(TcpClientclient) { using (varstream = client.GetStream()) { stream.Write(quote, 0, 1); // write header while (true) { WriteStockQuote(stream); } } }
DefaultConnectionLimitHKLM\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\MaxConcurrentRequestsPerCPU)ServicePointManager.DefaultConnectionLimit.Few ways you can do this.Best way is to do in global.asax.// See http://blogs.msdn.com/b/tmarq/archive/2007/07/21/asp-net-thread-usage-on-iis-7-0-and-6-0.aspx /* 5.If your ASP.NET application is using web services (WFC or ASMX) or System.Net to communicate * with a backend over HTTP you may need to increase connectionManagement/maxconnection. * For ASP.NET applications, this is limited to 12 * #CPUs by the autoConfig feature. * This means that on a quad-proc, you can have at most 12 * 4 = 48 concurrent * connections to an IP end point. Because this is tied to autoConfig, the easiest way * to increase maxconnection in an ASP.NET application is to * set System.Net.ServicePointManager.DefaultConnectionLimitprogramatically, * from Application_Start, for example. Set the value to the number of concurrent * System.Net connections you expect your application to use. I've set this to Int32.MaxValue * and not had any side effects, so you might try that--this is actually the default used * in the native HTTP stack, WinHTTP. If you're not able to set * System.Net.ServicePointManager.DefaultConnectionLimit programmatically, you'll * need to disable autoConfig , but that means you also need to set maxWorkerThreads and maxIoThreads. * You won't need to set minFreeThreads or minLocalRequestFreeThreads if you're not using classic/ISAPI mode. * */System.Net.ServicePointManager.DefaultConnectionLimit = int.MaxValue;MaxConcurrentRequestsPerCPUYou can insert maxConcurrentRequestsPerCPU in aspnet.config like following<system.web> <applicationPoolmaxConcurrentRequestsPerCPU="5000" maxConcurrentThreadsPerCPU="0" requestQueueLimit="5000"/> </system.web>Of you can do following in registryHKLM\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\MaxConcurrentRequestsPerCPU = 5000It's not clear if you have v3.5 SP1, which is required in order to set the value in aspnet.config, so please try the registry change and restart IIS.autoConfigSpecifies whether to automatically configure the following settings to achieve optimal performance based on the machine configuration:The maxWorkerThreads attribute.The maxIoThreads attribute.The minFreeThreads attribute of the httpRuntime element.The minLocalRequestFreeThreads attribute of the httpRuntime element.The maxConnection attribute of the <connectionManagement> Element (Network Settings) element.The values are set according to the KB article at http://support.microsoft.com/?id=821268.This attribute does not affect the .NET Framework client applications; only ASP.NET applications.The autoConfig attribute can be one of the following values.TermDefinitionTrueIndicates that ASP.NET automatically configures the attributes in the preceding list to achieve optimal performance based on the machine configuration.FalseIndicates that ASP.NET should use the explicitly defined values for the attributes in the preceding list.The default in the Machine.config file is True, unless there is a previously existing configuration.