Tag: Performance

Set CacheControlMaxAge to High Number

It’s a good practice to set the CacheControlMaxAge attribute in web.config to a high number.

		<!-- Set expire headers to 30 days for static content-->
		<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />

Turn On HTTP Compression

It’s a good practice to enable HTTP compression for any uncompressed content. Add the following code snippet in web.config.

	<!-- GZip static file content. Overrides the server default which only compresses static files over 2700 bytes -->
	<httpCompression directory="%SystemDrive%\websites\_compressed" minFileSizeForComp="1024">
		<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
			<add mimeType="text/*" enabled="true" />
			<add mimeType="message/*" enabled="true" />
			<add mimeType="application/javascript" enabled="true" />
			<add mimeType="application/json" enabled="true" />
			<add mimeType="*/*" enabled="false" />

Remove Unused View Engines

By default, ASP.NET MVC loads both the Razor and Web Forms View Engines. This can cause performance issues. Because ASP.NET will look for Web Forms views first, and switch to look for Razor views if Web Forms views cannot be found.

This can be resolved easily by adding the following 2 lines to the Application_Start method in Global.asax.cs.

ViewEngines.Engines.Add(new RazorViewEngine());

Performance Counters

How to Configure Performance Counters

  1. Click Start, and then click Run.
  2. In the Open box, type perfmon.msc, and then click OK.
  3. Expand Performance Logs and Alerts, right-click Counter Logs, and then click New Log Settings.
  4. In the Name box, type a name for the log, and then click OK.
  5. Click the General tab, click Add Counters.
  6. In the Add Counters dialog, add the following top 10 performance counters
  7. Set the Interval to 1 hour.
  8. Click the Log Files tab, and then do the following:
    a. In the Log file type box, click Text File (Comma delimited).
    b. Click to select the End file names with check box, and then click yyyymmdd.
  9. Click the Schedule tab, specify the start and stop times for the counter log, and then click OK.

Top 10 Performance Counters

  1. Processor(_Total)\% Processor Time  –>  Drill down if > 85%
  2. Processor(_Total)\% User Time
  3. Processor(_Total)\% Privileged Time
  4. Memory\Pages/sec  –>  Drill down if > 20
  5. Memory\Available MBytes  –>  Drill down if < 4MB
  6. LogicalDisk\Avg. Disk Queue Length  –>  Drill down if > 2
  7. LogicalDisk\Disk Bytes/sec
  8. LogicalDisk\Free Megabytes
  9. Network Interface\Bytes Total/sec
  10. Network Interface\Output Queue Length  –>  Drill down if > 2