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

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)

Related

IIS only processing one request at a time

We have an asp.net web application that works fine in our environment. One of our partners tries to the exact same code in their environment and can only process one request at a time. For example, there is only page that calls a long running stored procedure (5 minutes). If you call that page and the try to open a new page, the new page won't serve until after the first page has completed. We can see the request back up by looking at the worker processes for their application pool. They are running IIS 8.5 on a windows 2012 server. They're also running SQL Server 2016.
The database connection is structured the same as as in our environment. The stored procedure is not wrapped in a transaction. Any ideas what might be causing this behavior?
IIS also can work in the Debug mode, when it is enabled, Asp is limited to processing one request at a time in a single-threaded manner.
Open “InetMgr” or IIS manager, double click ASP under the IIS section of the website. Check the below settings in Asp section.
See the below discussion for more information.
IIS7 - only serves up one page at a time. It's a making me crAzY!

Make Cassini (VS Development Web Server) Stop Overriding My 404 Responses

I have noticed that while debugging my site, any request that results in a 404 and appears to refer to a path on the disk relative to my configured virtual directory is intercepted by Cassini and rudely replaced with a directory listing. I'm using Nancy Framework, but given that this problem appears to be at the web server level, I suspect Cassini would act the same way for MCV applications. I can't find any documentation on this "feature" other than a related commit message on the Cassini source that says "...directory listing only overrides 404 responses for directories".
I would much rather my development web server stop trying to outsmart my framework. I makes the debugging experience more than a little jarring. In an MVC framework the request URLs have nothing at all to do with file locations, so the fact I'm getting directory listings for some invalid requests and the correct 404 page for others gets annoying. Not to mention it's making several of my unit tests fail because they rely on auto-generated content in my 404 error pages (which I can't manually test either).
Is there any way to disable this functionality in Cassini? I know I could install IIS Express, but I'd rather not. Especially since my unit test runner and hosts file (this is a multi-domain application) are already configured just right.
Stop using Cassini and start using IIS Express instead.
Cassini has many shortcomings (SSL support being one, the problems you are seeing another and many more).
IIS Express is based on IIS code and is as close to IIS as can be while still being lightweight.

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.

IIS express requests take 4 times longer to execute

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.

Very weird IIS6 asp.net website behaviour

I have a weird issue with my website. This is asp.net(.net 3.5) website hosted on a dedicated server IIS6.
Recently I got a strange behavior, the website hangs and just doesn’t reply unless I go to iis and restart either app pool or whole IIS - BUT what is the most strange thing is that in case I go to remote desktop of the server and try to access it locally it DOES work just fine.
I read couple threads about deadlocking and hanging because of memory leaks and non closed sql connections BUT why it still does work from the local?
In case there is something wrong with the code – why does it still work from locally?
In case there is some issues on the hosting side (like firewall issues) then why does iisreset help?
Any thoughts would be appreciated. Thank you!
We've just run into this problem, and we have a solution. IIS has two thread pools to handle requests. One thread pool is used for external requests. Another pool is used for local requests. Our problem was caused by a deadlock in backend code. Once the deadlock occurred, all external requests were queued but not serviced because all of the servicing threads were in use. Opening the website from the web server uses the other thread pool, so the requests are serviced. We were absolutley positive it was a network issue, but WinDbg proved otherwise.
See here for more information:
MSDN blog entry about IIS and threads
minLocalRequestFreeThreads
(Also, search for minFreeThreads to see the non-local request thread pools.)
Good luck!
Are you sure that the website hangs for all external users, so that it's not just one single user?
The IIS only runs one page at a time for each user, so if one request is caught in an eternal loop, that single user will experience that the server has stopped completely as no pages at all work until that page times out. The server will still work as usual for other users.
You can test this by using a different browser, or starting a new instance of the same browser (possible with IE, not with Firefox).
Hmm not enough info to really give you an answer, but I would look at your firewall first if it responds locally from the server. Do you have another server behind the FW like a SQL server? Try browsing from that as it will show you where the problem is.
My though would be a badly configured load balancer.

Resources