IIS express requests take 4 times longer to execute - asp.net

I have uploaded the WCAT results run on windows 7, same script, to
ts: included XSL in zip. sorry.
Here is what I have noticed:
IIS Express has slighter higher requests per second, and total transactions served than normal IIS.
IIS Express is executing up to 100 requests at a time, while normal IIS on windows 7 is limited to 10 as designed.
IIS express is using 30% higher cpu, probably because of additional requests it handles at a time.
But on average Express requests take much longer to complete..up to 4 times longer. see Request Execution Time performance counter and time analysis (first and last byte).
IIS Express is only able to beat IIS in total requests served because it can handle more requests at a time!
Theories on what's happening:
Could the fact that IIS express is printing each request to command line window even with trace set none be slowing it down?
I also noticed a lot of additional modules registered in IIS express applicationhost.config that are not in IIS applicationhost.config. Could then extra debugging/tracing modules be causing the problem?
I notice IIS express does not have FileCache and HTTPCache modules. Could that be why?
I'm hoping asp.net experts can clarify how these results are possible if IIS express is not limited.

By default failed request tracing is enabled for IIS Express. You may see some performance gain if you disable it. (set enabled="false" for traceFailedRequestsLogging element in applicationhost.config)

Connecting the dots: http://forums.iis.net/p/1175052/1969390.aspx#1969390. Same question was asked on the iis.net forum as well, and it trigerred lively discussion.
Just to clarify, the IIS Express is primarily meant as a web development tool that provides a superset of functionality over the Cassini development server. Performance was not top priority for this release. It is true that IIS Express doesn't have connection limit, but the XP compatibility came at cost.
For the applications with mostly dynamic content, the overhead of IIS express should be acceptable.
for websites with lot of static content, the lack of http.sys kernel caching and also user mode caching will make a huge perf difference
Try to redirect the stdout to nul. It will boost your perf by a little bit.

Related

First request is very slow after website sits idle with ASP.NET MVC 3 (IIS7)

I developed a project in ASP.Net MVC 3, my hosting is using iis7 (Win Web Serv 2008 R2), and the first request after the website sit's idle (during about 1-2 hours) is very slow.
I use VPS with 512Mb RAM. Can this be related with a too little RAM?
Can anyone help me with possible causes of such behaviour?
After a certain amount of inactivity IIS unloads the AppDomain. And then the first request loads the application once again which is slower. You could try to configure this period in the properties of IIS but there might also be other causes that an application unloads such as for example a certain threshold of CPU or memory usage is reached. Those thresholds are also configurable in IIS.
That's not something specific for ASP.NET MVC. It's true for all ASP.NET applications in general.
We had also this problem with ruby and passenger that takes the app out of memory after a while, but I found a nice application that fixed this issue for us without changing anything in the server configuration, the app is called wekkars, and you can find it here: http://www.wekkars.com

How to warm up an ASP.NET MVC application on IIS 7.5?

We would like to warm up an ASP.NET MVC application hosted on IIS 7.5 server. The warm up module that used to be available at http://forums.iis.net/t/1176740.aspx has been removed since sometime.
The application should be warmed up everytime IIS or ASP.NET worker-process restarts for any reason. During the warm up period, IIS should return some HTTP status code signifying its warm up state or its inability to serve any clients.
Would creating a executable that navigates through necessary pages in the site via HttpRequests be a good idea? The executable can be triggered from IProcessHostPreloadClient implementation. Is it possible to configure IIS so that it would only accept requests from localhost and once the executable is done, it can switch over to all clients - but that switch should not trigger an IIS restart (obviously).
Is it possible to use an Visual Studio 2010 - Web Performance Test to warm-up an application instead of creating an manual executable? Any other alternatives?
PS: The application uses Forms Authentication and uses sessions - so maintaining state cookie and other cookies is important.
UPDATE 1 - We are using .NET Framework 4.0 and Entity Framework (database first) in our application. The first time hits to EF queries are slow. The reason behind the warm up is to get these first time hits out of the way. We are already using compiled queries at most places and we have implemented pre-compiled views for EF. The size of the model and application is very large and complex. Warm up needs to walk through many pages to ensure that compiled and non-compiled EF queries get executed at-least once before any end user gets access to the application.
Microsoft has released a module that does exactly what you ask for. The Application Initialization Module for IIS 7.5 improves the responsiveness of Web sites by loading the Web applications before the first request arrives.
You can specify a series of Urls that IIS will preload before accepting requests from real users. I don't think you can get a true user login expereince, but maybe you can set up simulated pages that does not require login that fulfills the same warmup you ask for?
The feature I think is most compelling is that this module also enables overlapped process recycling. The following tutorial from IIS 8.0 include a step-by-step approach on how to enable overlapped process recycling.
When IIS detects that an active worker process is being recycled, IIS does not switch active traffic over to the new recycled worker process until the new worker process finishes running all application initialization Urls in the new process. This ensures that customers browsing your website don't see application initialization pages once an application is live and running.
This IIS Application Initialization module is built into IIS 8.0, but is available for download for IIS 7.5.
You may take a look at the following post for the Auto-Start feature built into IIS 7.5 and ASP.NET 4.0.
Any application that generates a server request for the hosted resources can be used to warm up an IIS process. Exactly how many requests you need depends on what parts need warming up. Typically, warm-up is used for:
Starting up a worker process. For this, you only need to ask for one resource to warm up a process for the entire application.
Perform any static initialization, database startup, or pre-caching. Anything you do in your Global.asax file will happen when you do your first request, so if you can make all of your initialization happen then, you'll still only need to make one page request.
Force pre-compilation of ASP.NET pages. For this to happen you would need to hit every page. Fortunately, this is typically not much of a time cost, so you likely don't need to worry about it. If you do have individual pages that load slowly, you can warm them up separately.
The "warm-up" process here isn't anything magical. You just need force IIS to serve the URL in question. Everything you mentioned would take care of that: using a stress-test tool to query the URL, writing a custom utility to post HTTP requests, even just scripting out a tool like 'wget' or a PowerShell script to download the URLs would do it.
As far as restricting access to localhost, as far as I know, within IIS, the only way to change that requires you to restart IIS. You could always build a pre-request hook into your application and maintain the state there, and have your warm-up process query some specific URL that toggles that state to "open". But I'm not sure what you would accomplish. If, somehow, a user did try to query your site before your warm-up finished, all that would happen is your site would take a long time to respond, then they would eventually get the page they asked for. If you locked them out of the site during warm-up, they would instead get a browser network error that claimed the site was offline, which (to me) sounds much worse.

asp.net mvc 2 website MUCH slower on IIS 7.5 vs built-in server

I am taking some time to learn how to develop asp.net mvc2 websites, but I'm used to working directly off IIS instead of the built-in web server that uses the random ports when you hit F5.
but I've noticed that using the built-in webserver, requests fly and are immediate. I am using only the default project with the Home and About pages as it comes out of the New ASP.NET MVC 2 Project settings, no database connections, nothing beyond the base install...
but when I setup the IIS website and pointed it to the same directory, each request takes at least 3-5 seconds to complete, sometimes more.
this isn't just the "load" on the first request. EVERY request takes this long on IIS.
but if I F5 and test the project once again, everything zips and the responses are immediate.
What might i have configured incorrectly?
this is on win7 x64 by the way
You can check with a tool like firebug what takes the longest time in the request. If you use firebug it will tell you which part of the request cycles takes a certain amount of time. (I once used this when I encountered problems with the localhost URL, Firebug told me that the DNS request took about 2 seconds while using 127.0.0.1 took 1ms (using google I found out that was an issue due to ipv6 enabled)). So try tracing the requests with Firebug.
If the request to IIS is performed quite fast and the browser is waiting for a response for a long time it must be in the handling of IIS (the built-in server and IIS are different). In that case you can try reinstalling IIS (to make sure no plugins or other data is in IIS making the site slower) by removing and adding IIS via the windows components.
If that still doesn't solve the problem try tracing on the application via the built-in tracing capabilities of ASP.NET (http://msdn.microsoft.com/en-us/library/wwh16c6c.aspx)

How would you compare IIS & Cassini as production servers?

I have an ASP.NET website which is running currently on IIS. Now I want to move that site to run on Cassini.
What are the advantages of Cassini over IIS? What are its disadvantages?
What are your experiences using Cassini as a production web-server?
As far as I know, you cannot use Cassini in production because it listens for localhost requests only. You will have to modify source code and recompile the webserver by yourself.
Another thing is that IIS is built on top of http.sys kernel-level library for maximum performance. I'm not familiar with the latest Cassini versions but last time I checked, it used slower managed TCP sockets.
If your website is not very popular and Cassini has all the features you need, why not... there is nothing wrong with Cassini. It's simple webserver but it's not the only alternative to IIS.
There is Abyss, UltiDev Cassini and I think a few other open-source servers with ASP.NET support.
UltiDev Web Server Pro is a free, redistributable, light-weight web server with lots of enterprise-level feature for ASP.NET applications (from ASP.NET 1.1 to 4). Unlike Cassini, its design has nothing precluding it from serving Internet-facing applications. Created by UltiDev, the vendor of UltiDev Cassini fork, new UWS Pro is functionally closer to IIS than to Cassini. More screenshots.
.
Easy choice: it's simply not possible to use Cassini in production, because it's not accessible from remote machines (it only listens on localhost).
I would say you are better off, going with something proven to handle scaling, like mod_mono on apache if you are looking for alternative servers.
The integrated pipeline, routing, compression and caching features of iis are hard to replicate. But the app pool and failure rapid response stuff is hard to do without knowledge of the OS and the network stack at a root level.
Cassini doesn't claim to be multi threaded or handle any of the advanced e-tags or other header control issues that can be issues with iis, but are also usually set at sensible defaults in later versions of iis.
For the sake of completeness, you could do the older rails-mongrels model, spin up say 10 cassini's on ports 10100 - 10110, then use ngenx or apache to load ballance requests on those threads, and using a monitoring tool to redo requests to new threads when old ones go out to lunch and constantly be restarting 2 or so ports, because you get overloaded.
There is a good comparison of Cassini and IIS here at StackOverflow
There is no possible angle you can look at cassini or any of it's derivatives and consider using it as anything other than a development/testing server.

ASP.NET Web Services troubleshooting?

Working with one of our partners, we have developed now two separate sets of web services for their use. The first one was a simple "post to an https URL" style web service, which we facilitated by building a web page in ASP.NET that inspected the arguments in the URL, and then acted accordingly. This "web service" (if you can call it that) has been very stable.
At some point, the partner asked us to begin using SOAP based web services. At their request, we built them a new set of web services largely based on the previous objects, reimplemented as an actual "Web Service". This web service has not been very stable: around once a week, Nagios will alert us that our web service is not responding - and a quick iisreset does the trick.
Analyzing the log output and working in a debugger has not led us to anything concrete. The volume on this new web service is actually much lower than the HTTP web service. I think this could be a code problem or a platform problem, or of course something in between.
We've tried, with little improvement:
To duplicate the behavior in the lab
Debugging in the Visual Studio debugger
Tinkering with IIS options to give it its own application pool
My question, what are the next steps for troubleshooting?
Environment:
Windows Server 2003 Standard Edition R2 Service Pack 2 32 bit, Visual Studio 2005, MS SQL 2005, .NET Framework 2.0.50727
You may get some answers by profiling your webservices and understanding how they are using their resources. perfmon and procmon are both very useful tools in this regard.
EDIT: Since you say errors happen after about a week, the only thing I can think of is resource usage. Ensure your DB connections are being cleaned up, and any opened files (system call to the exe) are being closed.
Also, if your webservices can tolerate it, IIS has a setting that triggers a periodic recycle of an App Pool to handle cases where performance degrades over time. Its dirty, but it may work well for your case.
Since there isn't much to go on - here's another odd issue we came up against regarding our web services.
When the web service stops responding how is memory utilization? We have experienced issues with memory and memory fragmentation relating to busy web services on a system (there was also other things running causing additional fragmentation). When we re-factored the web services to load from smaller dll's and depend on other libraries (instead of one large library) we were able to resolve the memory fragmentation.
To identify what was occurring we would take a dump from the offending iis worker process where the app pool resided and then reviewed that using WinDbg.
http://www.microsoft.com/whdc/devtools/debugging/default.mspx
Additionally we used DebugDiag to take the postmortem dumps.
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1286
Hope this provides another direction to look at.

Resources