IIS7 slow appPool startup compared to IIS6 - iis-7

I have recently purchased some new windows server 2008 boxes all running IIS7.
I have moved some of my websites across to them, but they seem to be running VERY slow when the app pool first kicks in.
All the sites are precompiled (using webdeploy) and in IIS6 they were lightening fast, I thought it might have been just because the web apps are fairly large but I get the same issue on smaller ones too.
The app pools are set to Classic mode, as we couldnt get the urlMapping to work in integrated mode.
I have seen a few posts about the slowness on the net and one post on here about it and people throwing stupid answers around such as its because your code isnt compiled or its to do with JIT, and both answers are pretty much a word that rhymes with JIT but has an extra letter. I say this because I have run much larger web apps in IIS6 and not experienced this lag.
Thanks for anything that you bring to the table on this.
edit:
just done some timings and it can take up to 28seconds for the first request to return a page...

This was slow due to using Classic Mode, I have moved it to integrated pipes which is faster at around 9 seconds load time, which is still unacceptable, but I believe this is an application issue now not IIS.

Related

.NET applications load extremely slowly in IIS-8 Windows Server 2012

After perusing stack exchange & numerous MSDN articles for months, I'm coming to the community looking for help. I'm the IIS Admin for my organization & I've been seeing an issue wherein when a change is made to a .NET application, the page takes a very long time to load when a request is first submitted to the page. When I say a long time, I'm saying anywhere from five minutes to a half hour at times. I've tried a number of items to fix the issue. But it's my belief that there's a configuration setting buried somewhere that is causing the issue. Once the page loads once, it's load time is normal going forward. It seems to happen regardless of the application, although some take longer than others. It's also not consistent. Sometimes it'll take seven minutes to load after a change. That same application may take seventeen minutes to load the next time a change is made... The changes are usually very minor, a new image box is moved in, or a new link added. Nothing major.
If an app takes twenty seconds to a minute to load the first time, we're not concerned. But the ten, fifteen minute, sometimes half hour load time is what is not acceptable.
The issue happens regardless of whether or not it's a static content application, or if it's reaching out to a data source. Any connections to a data source are configured at the app level. We only utilize that on a handful of apps & I verified the connection information is valid in the web.config for those apps that do reach out to a data source. We're using Windows Authentication on every app.
We run a three tiered environment, all running Windows Server 2012 R2 Standard with 16gb of ram & a multicore CPU setup. We're running IIS 8.5 on .NET 4.0.30319. The app pool is utilizing the integrated pipeline with support for 32-bit apps (which the apps are). These are VMware Hosts. The server is rebooted once a week.
The issue does not occur on our test or dev servers. Only our production server. It doesn't matter what time of day the change is made.
In December of 2016, I ported over all of our .NET applications from an older Windows 2003 system running IIS 6.0 to the new Windows 2012 system. While we worked with the developer to alter any hardcoded hostnames in the apps, we ultimately had to install a CNAME host record to re-direct the old hostname to the new one. The issue seems to have started around this time.
One issue I noticed was that the developer was compiling all apps in debug mode. We changed this setting to false, but it only marginally helped in some cases.
I tried the following as well:
Segregated a given app & set the app pool to always run. Also tried changing the application pool identity to run as a network service, or as a service account user.
Adding the application initialization role & configuring in IIS to always run the app pool & enabled preload at the app level. - I backed this out when I saw it made no change.
I married up all the roles between our test/dev servers where the issue doesn't happen with that of production.
Disabled idle timeout at the app pool level.
Compared settings between test & production regarding compilation settings, time-outs, etc
None of these changes made any difference. I can't find anything differentiating the test/dev boxes where there is no issue & the production problematic server. Please let me know what additional information you may need & I appreciate the help in advance!!
Thanks,
Mike
We found the problem. Our AV software was the culprit. Specifically Trend Micro Deep Security.
When a request was made & the program was going to compile in the temp area (C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files) - I noticed it seemed to be taking a very long time for the files to build out. Pre-compiling saw the same behavior. I asked our LAN admin to add an exception for this particular folder. Once that was done, it's only taking 5-10 seconds on first load, which is acceptable. Thanks again for your input.
You want to precompile your pages so they don't get compiled on first run. IIRC it's just a simple web.config addition.
https://msdn.microsoft.com/en-us/library/bb398860.aspx
Though to be honest, compile times of 5 minutes per pages seems like there's a bigger problem going on. I've never seen a new aspx compile take longer than a few seconds.
Neil N's answer makes sense, but I'd definitely check and see if that setting is the same across all of your servers.
If that isn't the culprit, my next stop would definitely be looking at the 'Application' section of Event Viewer. It could be throwing some meaningful warnings to help you get closer to the root of the issue.

Slow page refresh times during development

We have a reasonably large ASP.NET MVC app that I work on in Visual Studio 2012 on Win 8. I have a strange issue with slow page load times after recompilation. Usually, the actual build time is about 5 seconds, then the browser opens up and it takes 1-2 minutes to load the page.
Some points:
It loads slowly whether I change a view or recompile the project completely
This is not a performance issue, everything else works really well, there is enough RAM etc.
It happens only with IIS Express. When I switch to the default development server, it works fine.
All the other devs in my team use IIS Express, but they do not have this problem.
I tried to re-install IIS and to use v7.5 instead of v8 and recreated all config files. No luck.
I tried to disable all extensions, obviously it didn't affect load times too.
There is nothing abnormal in Task Manager
It's a virtual machine on my Macbook Pro, but again – this is not a performance problem.
What else can I try?
Solved by turning off Windows Defender Service. Everything is a hundred times faster now.
UPDATE: I failed to find a reason why Windows Defender is using lots of CPU power pretty much all the time. I tried to google it and it turns out that many people have a similar problem on Win 8 with no good solution.
If you really want to leave Defender on, you can add the project folder path as an exception, but it still will be slow-ish.
Hope it helps someone.
UPDATE 2: The above still holds true in Windows 10. Especially if you're running it in a virtual machine (I run it in Parallels on Mac). The overall speed increase, not only page refresh times, is very noticeable.
UPDATE 3: Apparently Windows Defender has a habit of silently turning itself back on again. So, be wary of that.
After viewing this question and answer above I found that Windows Defender Service was already turned off for me, however, I was running AVG. I disabled AVG and sure enough the lag went completely away!
So if Windows Defender Service is turned off for you and you are running some sort of system protection like AV try disabling that.

What are some reasons ASP .NET startup would be so slow

I have Visual Studio 2010 and a pretty large web application project running on IIS 7. Startup for the web application is over a minute (75 seconds). I've attached ANTS to it and very little of the 75 seconds is my code. Most of it seems to be something like CreateAppDomainWithHostingEnvironment and BuildManager stuff. Now I know that ASP .NET will compile dynamically the first time but I certainly don't expect it to compile for that long. Why could I be experiencing this problem and what are some ways I can try to fix it or try to better understand what is taking so much time. Aksi the CPU utilization doesn't seem to be that high. I have an awesome machine.
The problem with the 75 second startup is that for developers working on this, everytime they make a change they have to wait this 75 seconds.
I am using .NET 4.0
EDIT
I ran Microsoft Network Monitor on my machine to see if there was anything suspicious going on the network. There wasn't as far as I can tell though i wasn't sure what to look for (I am familiar with network monitor though so I did have an idea of what I was doing). I tried to run it in release build and though it may have improved the performance a little bit its not really significant
EDIT
I have SQL Session state. As far as i can tell, the connection string is pointing local. For some reasons though, when examinning ANTS, i'm getting a lot PollLockedSessionCallback on many threads. The function seems to be called over 70 times. Does this help at all?
Try building the application in release mode. You can set this in the Build tab of the properties window. You might also consider pre-compiling when publishing the application before deployment.
Are you trying to access anything via a network share at startup? If so, bring those resources local for startup comparison.

IIS memory leak detection techniques

I have a server running about 100+ WordPress sites of varying complexity and traffic volume. The OS is Windows 2003 Server running IIS 6 with the domains being managed via HELM. The thing is there are times when sites stop responding due to insufficient memory, but it has been difficult to track the particular site(s) or other culprit that could be the cause. What makes it even more complicated is that the problem will disappear for weeks and then show up again. The most recent solution was to migrate the sites to a higher capacity server and this seemed to have worked for some time.
What tools/techniques can I use to track down the problem while keeping in mind that this is a production server?
Tess Ferrandez has a number of great articles about tracking down memory pressure and process hangs in IIS using WinDbg and DebugDiag:
If it is broken, fix it you should
Whilst the techniques often focus on ASP.NET, many of the techniques can be applied to other languages. The only problem is that because PHP is written using native code your WinDbg-fu will probably need to be fairly good.

SharePoint - "Request Timed Out"

Anyone got tips for diagnosing SharePoint / ASP.Net "Request Timed Out" messages?
We've recently taken on the support and development of a client's MOSS public facing website. We've recreated a version of the site (a manual process - no Solution's here!) on 3 separate dev servers and are experiencing extremely slow warmup times. I'm used to waiting up to a minute after an IIS Reset but we are having to go through 2 Asp.Net "Request Timed Out" error messages. In general the site seems to be taking about 5 minutes to load up. Try doing custom development against that!
The strange thing is that on the staging and production servers the site takes about 40 seconds to warm up. They are slightly more powerful servers with a separate DB server but I wouldn't have thought the difference should be that great? I don't have any trouble with other SharePoint sites on my dev servers - just this one. It does contain a lot of custom code and DLLs so I understand that it may take a little longer to load these up but 5 minutes seems ridiculous.
The servers I'm testing this on are SharePoint 2007 (Feb CU), Win2003/IIS6, SQL 2005.
Does anyone have any tips for diagnosing the bottleneck here? I'm not sure if this is expected behaviour or a problem somewhere in the stack?
Cheers,
James.
Have you run any performance monitoring over the servers? This is essential for finding where the bottlenecks are. See here and here for recommendations.
If custom code has been deployed, check for an unusually high exception count or garbage collection/memory leak problems. This is most likely to be where the problem is. The best way to narrow this down is with a tool such as ANTS Profiler which will show memory leaks and performance issues. You could also Turn on ASP.NET tracing and set debug="true" in web.config and get some idea on slow executing code (although with all those timeouts this might not be so helpful).
Also do you know if any regular maintenance was performed on the SQL Server? (See some tips here.) Has SharePoint SP2 been installed (this performs some reindexing for you)?

Resources