How to achieve the best performance of my website

There is no!

I am running IIS7 on a Windows 2008 server.
At the time of peek, we have the following behavior:

  • CPU utilization is almost inactive
  • Requests are queued (monitored using the resource monitor)
  • Run time exceeds 10 seconds

1-4) See previous versions and changes

5) Perform asynchronous work

As I said, I created a simple web page ... one page ... with this code:

using System; using System.Threading; using System.Web; using System.Web.UI; namespace PerformanceTest { public partial class AsyncPage : Page { protected override void OnInit(EventArgs e) { base.OnInit(e); var pageAsyncTask = new PageAsyncTask(this.BeginAsyncOperation, this.EndAsyncOperation, this.TimeoutAsyncOperation, null); this.RegisterAsyncTask(pageAsyncTask); // or //this.AddOnPreRenderCompleteAsync(this.BeginAsyncOperation, this.EndAsyncOperation); // this might be useful for doing cleanup or sth alike this.PreRenderComplete += HandlePreRenderComplete; } private void HandlePreRenderComplete(object sender, EventArgs e) { this.Trace.Write("HandlePreRenderComplete"); this.Trace.Write(string.Format("managedThreadId #{0}", Thread.CurrentThread.ManagedThreadId)); } private delegate void Sleep(int miliseconds); private IAsyncResult BeginAsyncOperation(object sender, EventArgs e, AsyncCallback asyncCallback, object state) { this.Trace.Write("BeginAsyncOperation"); this.Trace.Write(string.Format("managedThreadId #{0}", Thread.CurrentThread.ManagedThreadId)); var sleep = new Sleep(Thread.Sleep); return sleep.BeginInvoke(1000, asyncCallback, state); } private void EndAsyncOperation(IAsyncResult asyncResult) { this.Trace.Write("EndAsyncOperation"); this.Trace.Write(string.Format("managedThreadId #{0}", Thread.CurrentThread.ManagedThreadId)); } private void TimeoutAsyncOperation(IAsyncResult asyncResult) { this.Trace.Write("TimeoutAsyncOperation"); this.Trace.Write(string.Format("managedThreadId #{0}", Thread.CurrentThread.ManagedThreadId)); } } } 

Sounds pretty good, right? In fact, it does not change anything, since the voltage is more than 30 seconds, the response time increases to 8 seconds when using a processor of about 0%.

6) Updated machine.config file

 <system.net> <connectionManagement> <add address="*" maxconnection="12" /> </connectionManagement> </system.net> <system.web> <processModel autoConfig="true" maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50" minIoThreads="50" /> <httpRuntime minFreeThreads="88" minLocalRequestFreeThreads="76" /> </system.web> 
+6
source share
4 answers

You are using a page, and possibly a session, so every page load blocks everyone else because of the session.! Thus, you can call it Async or call PageAsyncTask , but the page blocks all other calls due to the session, and page calls get in line for execution.

Disconnect the session for the test only, and then if you are not using any session data, save it for this page.

See also: Completing an entire ASP.Net session

Web garder

You can set up a web garden that provides more pools for the same web application. In this case, you need to re-check all your code and enable synchronization with the mutex or database lock, because with two or more pools the same data can be accessed and written by different streams.

http://msdn.microsoft.com/en-us/library/aa479328.aspx

+2
source

The answer to this question is quite simple:

Do not block the flow

The fact is that IIS and ASP.NET AppDomain can only handle N simultaneous requests. You can increase this number, but blocking completely on thousands of simultaneously running threads is a nightmare bottleneck. Not knowing what exactly makes an ASP.NET page respond in less than one second, it's hard to suggest any performance improvements, but the problem here is probably not in IIS, but in the code.

If the code blocks the thread for several seconds without actually doing anything (as the CPU uses), there is some kind of IO that is so slow that it should obviously be executed asynchronously. A web server can serve an almost infinite number of concurrent requests (limited only by available hardware resources) if these requests do not block threads. If they block threads, it can only execute as many requests as there are available threads that have a hard upper limit.

Do asynchronously

Rewrite the code so that it does not block the stream, calling the Begin... and End... method instead of its synchronous siblings. Async CTP can help with porting these Begin and End calls to code that looks synchronous, but the performance advantage here is so huge that you should consider rewriting any code that blocks the page, even without async stuff.

+1
source

We had a similar problem. It turned out that the problem is not in our code.

In our case, the problem was unloading TCP Chimney in Windows 2008 R2. Windows 2008 tries to be smart by offloading work to a network card, but if the network card gets the maximum load, everything slows down, but all normal performance values ​​show a small load.

http://www.iislogs.com/steveschofield/troubleshooting-iis-7-network-performance-issues-and-tcp-chimney-offload-receive-side-scaling-and-network-direct-memory-access

+1
source

Source: https://habr.com/ru/post/898189/


All Articles