Why is IIS slower than ASP.NET Development Server?
Asked Answered
T

1

5

I have an ASPX webpage that does some complex operations and database calls. When I view the webpage by running ASP.NET Development Server (Cassini), it takes about 200ms.

Then, without any code changes and configuration changes, I deploy the website to my local machine IIS 7 and view the same web page again. It takes 2.0sec, which is 10 times slower.

I thought IIS should be faster than (or at least as fast as) Cassini.

To investigate further, I created a new page, test1.aspx, which contains nothing but an empty for-loop that runs for 90 million times in the Page_Load. In Cassini, it takes about 200ms. In IIS, it takes 300ms (50% slower).

What could be the reason that makes IIS slower than Cassini? Or, perhaps an even better question, how can I make IIS run at least as fast as Cassini?

Thigmotropism answered 18/10, 2012 at 12:2 Comment(0)
T
10

Fast and short answer:

Configure the application pool used by the web application to enable 32-bit applications:

Set Enable 32-bit applications to True

Detailed walkthrough:

I used some performance profiling tools (some are free) to compare the performances and to find out the bottlenecks. The free EQATEC Profiler is good enough to allow me compare two reports generated from running Cassini and IIS and identify the method causing the problem. However, the method contains too many lines and I was unable to pinpoint the exact line causing the problem.

Then Redgate ANTS comes in handy. By profiling the method with line-level detail, I found that it was RegEx running very slowly.

Further searching leads me to the answer here: RegEx.Match is much slower in IIS compared to Development Server (Cassini). I am using Windows 7 64bit with IIS 7. Setting the "Enable 32-bit applications" to True solves the problem.


Also, a slightly related reading on running IIS as 32bit or 64bit:

64-bit servers are much more effective when used for databases like SQL Server, or other data management servers (let's say, an enterprise email server like Exchange), than for processing servers, such as IIS or the worker processes it manages.

It will require 64-bit pointers for every lookup, which will make everything a little slower.

Source: What are the pros and cons of running IIS as 32bit vs 64bit on a 64bit OS?

Thigmotropism answered 18/10, 2012 at 12:2 Comment(3)
You only listed a few corner cases, without mentioning that Cassini is simply a toy, without strong security/long pipeline/kernal-user mode separation/application pool (which can hurt performance, but are essential for a production level web server). Via scalability you can still serve many users with acceptable performance on IIS, while Cassini can never achieve the same level of robustness.Paranymph
@LexLi, I intend to make this page a repository of reasons that could make IIS runs slower than Cassini. Do you mind explaining, as separate answers, how the factors you mentioned could bring huge impact to IIS, and also ways to rectify them?Thigmotropism
Great thanks, i've wasted so much time searching for optimizations etc..now i know why my IIS is slow..Andradite

© 2022 - 2024 — McMap. All rights reserved.