How long does IIS retain compiled ASP.NET in cache before needing to be recompiled? - asp.net

I am testing a piece of software called PowershellASP which lets you run powershell scripts inside an ASP.NET page, which I am driving via IIS 7.
Basically, on my test page, the first time it loads it takes over 60 seconds, which I assume is because the ASP.net needs to compile? It is fast on subsequent loads, except it then goes back to requiring 60 seconds+ if I leave it for an hour or so and then try refreshing the page after an hour... Any insight on the likely culprit for this behaviour (i.e. its "slow" after I try to refresh the page after an hour or so)...
Is this the IIS cache expiring and thus needing to recompile the ASP.NET page I'm trying to load or am I barking up the wrong tree?
regards, ted.

EDITED:To increase the idle timeout of a iis application go to advanced settings of your application pool and change the idle timeout to 0. Default is 20 min. The IIS doesn't exactly compile your application it load it into a worker which can take some time based on your application and the iis settings. After some idle the iis automaticly unload your application to save resources, that is why it takes more time after a while. Ones the app is loaded it runs fast.

Related

IIS 10 on WinServer 2019 is loading asp.net pages very slow even on subsequent loads

My question has nothing to do with the initial page loads. My ASP.NET Web Site is running very slow, on IIS 10. Even when I refresh the page after a load, it takes minutes. What do I need to check?
Application Initialization Module is installed and running
App Pool is using Classic managed Pipeline mode and has Start-Mode set to AlwaysRunning
Preload Enabled in Website's setting is set to true
The same application runs fine on another server running older WinServer and IIS 8. What do I need to check?
This is embarrassing. Posting this answer so I find my own question the next time I run into this again, or someone else runs into this. My application on the other server where it runs, has caching configured so all the database pulls are cached. This new server has no caching set up. Those pulls are so slow, I am finally getting the hang of it.

Recycle and reload application pool on IIS7

Is there a way to recycle and afterwards reload an application pool?
My problem has been slow performance when logging in to my web application. I found out that the "Idle Time-out(minutes)" was sat to 20 by default. This caused the application to terminate when idle so that it can start up again on the next visit. After searching the web i found out that this value could be sat to 0 so it won't terminate. However, the first visit after recycling, an app pool have to create a new w3wp.exe worker process which is slow because the app pool needs to be created, ASP.NET or another framework needs to be loaded, and then the application needs to be loaded. Source right here
This means that every time the app recycles, the first visitor have to wait longer then the other visitors when logging in, doing some stuff and log out.
The web application is using the ISS from Dynamics AX 2009.
Sorry I thought you are working on IIS 7.5
But there was a beta for this in IIS7 actually.
I think you are looking something along the lines of this
A warmup module for IIS 7.5
"IIS Application Initialization for IIS 7.5 enables website administrators to improve the responsiveness of their Web sites by loading the Web applications before the first request arrives. By proactively loading and initializing all the dependencies such as database connections, compilation of ASP.NET code, and loading of modules, IT Professionals can ensure their Web sites are responsive at all times even if their Web sites use a custom request pipeline or if the Application Pool is recycled. While an application is being initialized, IIS can also be configured to return an alternate response such as static content as a placeholder or "splash page" until an application has completed its initialization tasks."
Download Link
http://www.iis.net/downloads/microsoft/application-initialization
And also have a look at this; which basically talks about using warm up classes which comes with ASPNET 4
http://weblogs.asp.net/gunnarpeipman/archive/2010/01/31/asp-net-4-0-how-to-use-application-warm-up-class.aspx
Checkout the suspend option.
IIS now has
Idle Time-out Action : Suspend setting
Suspending is just freezes the process and it is much more efficient than the destroying the process. Because it uses the same process and does not create another one after waking up.

asp.net application takes long to start--even after compiling

I have an asp.net app on IIS 7. It is 'pre-compiled', but I understand that IIS must still compile the assemblies the first time they're run.
Here is the problem--After I publish and deploy the application, I log in, and (as expected) it takes about 30 seconds to see the login page. Then I visit every page so that they are compiled (I have used the 'individual file for each page' or whatever option).
So far so good.
Then 10 minutes later i log in and it's near instantaneous. Still good and expected.
Yet the next day, my first logon takes 30 seconds or more again. Nobody changed web.config or copied any new assemblies in the meantime--this I am sure of.
Does anyone have an idea why this is happening? Is there an application timeout (as opposed to a session timeout)? Is there some setting in IIS admin console that I may have left at some default that is not optimal?
Thanks for any help on this,
James
Yes, starting an ASP.NET application in IIS is relatively slow. How much? It depends...
It's slow again the next day because IIS shuts down apps when they are inactive for some time.
The solution is "Application Initialization". This is built-in in IIS 8 and available out-of-band as a module for IIS 7.5:
http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-application-initialization
There is an Idle Time-Out on the Application Pool under Advanced Settings. Set this to 0 and the application will not stop due to inactivity.

Why is intranet so slow on our machines?

we are using IIS 5 + Windows XP on our machines,
they have Celeron CPUs # 2.6 ghz, 2 GB RAM
These machines have control system for machinery, control system logs events to database and we want to show reports for machinery usage, operator logins, etc.
We use Windows XP and IIS 5, our applications are ASP.NET (3.5). We use Sql server 2005 express and Crystal Reports 10.5 for reporting.
The problem is, that whenever you open an intranet page after reboot or after longer period of webserver's inactivity, it takes a LOT of time for a page to react, 10-30 seconds. When I open up a page that shows a report, it lags for this amount of time too.
When pages are viewed after the first long load, they render quickly.
The pages are precompiled (helped a bit, but not much), disk is not fragmented, sql server reacts fast (tested with other applications) - I really don't know what's the cause, but I'd like to eliminate it, because this looks very bad with the customer - to wait for half a minute for a report page to display.
Why is this so slow? I have done some sample pages on php/mysql/iis and it was lightning fast... Is there something I can do to 'preload' all of the intranet applications on machine reboot? If nothing helps, I'll make a simple script that will periodically request all pages from the webserver, so it will be 'warmed up', but this is a dumb solution, I think. :(
I guess probably the application pool for the web site is not loaded until the first request - this time is for the out-of-process host process to start running and serve up requests.
IIS takes a few seconds to compile each ASPX page after a recycle. You need to create a warmup script that programatically loads a few of your pages after the recycle. The script will incur the delay so your users don't have to.
Here is an example. http://blogs.msdn.com/joelo/archive/2006/08/13/697044.aspx It's for SharePoint, but the concept is the same and you should be able to adapt it.

How to keep ASP.NET assemblies in AppDomain alive?

Scenario: I've an n-Tier enterprise ASP.NET application deployed using Web Deployment Projects. All tiers produce independent assemblies that is consumed by the ASP.NET application.
Problem: When I run the app. for the first time after deployment it takes lot of time to load dependent assemblies in memory. But once loaded its lighting fast app. In case if there are no users accessing the app, IIS unloads the assemblies from the memory and when a user tried to access the app on a later instance it goes on loading all the assemblies once again taking the same amount of time to load as it takes to do so for the first time.
I'm looking for a solution that enables me to keep my assemblies loaded into memory persistently overriding the volatile nature of assemblies towards memory residency.
Or any other solution that lets my users happily use the app resolving the mentioned problem.
In IIS 6, go to the Application Pools section, and right-click > Properties on the pool which hosts the ASP.NET application in question. Go to the Performance tab and uncheck "Shutdown worker processes after being idle for:"
In IIS 7, go to the Connections pane and find Application Pools, and select Advanced Settings for the pool which hosts your application. Find the "Idle Timeout" property and set it to "0" (this disables it).
The default is 20 minutes of inactivity. By unchecking the box, once your AppDomain is loaded by the worker process, it will never die (unless you kill the process or something of course). By default, IIS will recycle the process when it reaches some limit, such as a memory cap, but it will also start a new one and "phase over" all incoming requests until the old one is unused, so as to minimize disruption.
I've also written a small c# class which will keep your ASP.NET application alive (alternate archived version) under normal circumstances. Since it runs within the application, obviously it can't stop IIS or anything else from explicitly killing the process, but it will keep the application "hot", e.g. the app will never go idle long enough for IIS to decide to shut it off.
If you do not have direct control over your IIS configuration (shared host, for example) your best bet is to have a small application running on a separate system - say, an always-on workstation - which hits your site every x minutes to keep the application pool from timing out. Nothing fancy - a simple WebRequest and a while() loop in a console application will do.
One of the advantages of ASP .net is the posibility to create static (shared) instances of objects.
To avoid the necessity of an external process you can create an static timer in (per example) global.asax which calls for a page on the domain with a simple WebRequest. On this way the site keeps alive himself until a manual reset of the pool is done.
I wrote a little C# console application that keeps my 4 sites alive every 10 mins via windows task scheduler. Life is once again good. We do not run the app from 2-5am just so the serves can do any cleanups of memory, if it even matters. for our sites there is rarely anyone on at those hours anyway.

Resources