IIS worker process overlapping - iis-8

I have an application hosted in IIS 8 and it's application pool is set to auto recycle after 10000 requests. But at times when an application pool is recycled. The new app pool keeps on overlapping.. and the old one doesn't get abandoned.
Expected result: App pool should not overlap after auto recycling.

Learn what is disallowOverlappingRotation,
https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/applicationpools/add/recycling/#attributes
Though you really should consider setting it to true and modify your web app to adapt to that overlapping behavior.

Related

Why does an application pool for ASP.NET Core in IIS take a long time to stop?

I developed a simple demo web app using ASP.NET Core 5 and published in IIS.
However, it takes a long time (over 30 seconds) when I press application pool stop button.
Application pool cannot be started before it is stopped completed.
I have not experienced it with ASP.NET MVC 5 web app using .NET Framework 4.6.1
Application pool using ASP.NET MVC 5 can be stopped and started in a few seconds.
It may make issue with application pool idle time of IIS.
Of course, I can set application pool idle time to 0 to prevent auto shutdown of application pool.
However, I want that my web app is restarted automatically when it is idle for a long time like midnight, because my web app (not a simple demo web app but actual product) can consume very large memories.
If application restarting time is long, my web service can be down before stopping and starting is completed.
It is also important to update web app – ASP.NET Core 5 web app requires application pool shutdown to overwrite files.
If web service downtime is short (under 5 seconds), it can be acceptable to my customers.
However, if it is over 1 minite, it can be not good at real world scenario.
Is there any way to decrease application pool restarting time of ASP.NET Core 5 on IIS?
Possible reasons:
Using Thread.Sleep somewhere in application. When thread is sleeping, IIS waits for 30 sec (by default, can be configured in web.config). Thread.Sleep can be replaced by await Task.Delay (see more variants there)
Using HttpClient in some objects destructors
Some another work in objects destructors.
I investigated similar problem by sequently removing code from application and trying to stop pool.

Web app deployed on kestrel goes into idle mode

I have ASP .Net core webapi deployed on IIS 7.5 (Windows 2008 R2). I have controllers as well as listener classes (which wait for a message to arrive on a RabbitMQ message) which perform the same functionality.
The problem is whenever webapi is deployed on IIS or has some idle time, the RabbitMQ messages don't get picked up. Only if I make a API call to the control does the application 'wake up' and picks up the message.
Tweaks I have tried:
In the application pool,
set 'Idle timeout' to 0 .
set the 'Disable Overlapped Recycled' to true.
set 'Disable recycling for configuration changes'.
I have no idea what is causing this. I need the application to pick up messages immediately and have no idle time. Could anyone please point me in the right direction?
As a complete workaround, you can keep your app alive by sending requests all the time. In my case, I don't even have access to changing IIS settings.
To send requests I use Availability feature in Application Insights -- it lets you create tests that send GET requests to your app as often as every 5 minutes. You can read more about it here.

IIS Application Recycle drops static classes

I'm using Simple Injector in my WCF service. While running it from VS2010 everything is fine. However, when I publish it to my server using IIS 7, after some time (20 min, counted) my WCF loses all registered assemblies, modules, classes in container.
I guess IIS recycles the WCF Service Application Pool and drops my container registrations.
Can anyone help me on this?
While there exists many legitimate cases of using self-hosting WCF services, however, approaching self-hosting just because of IIS recycling may be counter productive.
Hosting in IIS gives you a lot benefit during development and daily operations, and I am not going to repeat what benefits which you could easily find out in google search.
So when IIS receive the first request to your application, it will launch a worker process named "w3wp.exe" according the settings in the application pool associated with your web app. And by default IIS will shutdown in 20 minutes of idle time. Check the Advanced Settings of the application pool, you will find a lot settings for the life cycle. You won't get such flexibility and robustness through self-hosting out of the box.
So basically you could have a few options provided you decide to stay with IIS hosting.
Change the Idle Time-out to 24-hours or even a month.
Write a small program or use cUrl to ping your application every 10 minute.
Leave it as it is
If you want to keep states during operations, save them in disk, then load them during next launch triggered by a request.

WCF Service 404 Error on First Post

I have a WCF Service hosted in IIS 7.5 that is responding to the first soap message posted to it after inactivity with a 404 Error.(It works around 15 seconds after that...it is likely waking up after that initial ping.)
In investigating this issue I have:
-Prevented App Pool Recycling by setting the Idle Time-out to 0 and the recycling time interval to 0
- Attempted to enable the app warmer by installing Microsoft's App Inititializer and
amehrots app initializer ui for iis 7.5. Using this I set the application pool to always running and preloaded/preinitted my service.
- Installed http://keepalive.codeplex.com/ to run through the metabase and hit the service with activity.
While the service is active following an iis restart, it still appears to sleep after a period of inactivity. I am currently looking into reliable sessions and whether tweaks can be made to the web.config. Any further guidance would be appreciated.
There is an idle time setting on the Application pool.
The default is 20 mins, if there is no Activity for 20 mins the app pool is released from memory. The first Call after that will trigger a load and JIT compile of the code.
You can stop the shutdown by setting the idle time to 0.
I decided to give up on my attempts at an elegant solution and ended up adding a windows service to send a web request to each of the urls that I needed to keep alive.

IIS 7 Restarts Automatically

I have a WCF Service Deployed on IIS. (BasicHTTPBinding with [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)])
I have built custom in-memory session management and Now I am facing a strange problem that is IIS 7 Restarts Automatically without even throwing any kind of warning or error not even in EventLog. This problem leads to destroy the all available sessions.
I discovered this issue after logging the Application_Start and Application_End methods using log for net and also i put the break point in application_start and it paused there in between test execution.
This happens rarely but i need to know why it happens and if it is normal and acceptable or not. if not then what may be the possible reasons of this.
Regards
Mubashar Ahmad
Could it be the app pool being re-cycled? IIS 6 has this set on by default to 1740 minutes. As for IIS 7 I guess you would have the same kind of setting? I know in IIS 6 this "event" is not logged as 'n error.
IIS recycles worker processes either when it detects an "unhealthy" process, or after certain operator-configurable limits are reached.
Among the limits are:
memory threshold
after a configured number of requests
elapsed time
time of day
more info
The Session timeout (which is separate to the app pool recycling) is set to 90 minutes by default, this is set at the application level. This also means anything being held in Session will be blown away at that time. You can set it via the properties of the virtual directory/application in IIS6, and via SessionState->Open Feature in IIS7 (when you have the application selected).
Also note that session timeout can be set via the web.config of an ASP.Net application, should your web services be hosted in one of those.