Web app deployed on kestrel goes into idle mode - asp.net-core

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.

Related

.Net Core Slow after idle

I have a new .netcore web app deployed to a windows server 2008R2 IIS instance, and after the app has been idle for a while, it's slow upon first load, and then subsequent requests are super fast.
In previous versions of .net I changed the Idle Time-out property of the app pool in IIS to 0 to fix this issue. Is there a similar setting somewhere with .netcore, perhaps something I've missed I could add to the Startup.cs file?
How about setting up the Application Pool Idle time on IIS?
Also make sure the recycling settings are unchecked
Baring there being a legitimate fix as I am unfamiliar with .netcore; writing a route which returns an HTTP 200 or something as a heartbeat and then calling it from a scheduled task every X minutes(idle - 1) would prevent the application from ever idling and thus keep it from slowing down requests.

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.

WF4 delay/ resume in WorkflowServiceApplication on IIS5 and 6

I have my workflow hosted in a WorkflowServiceApplication running on IIS5 (production environment will be IIS6) with a persistence database. It's a request/approval service so there's a delay (a few days) whilst waiting for approval and if that delay passes with no approval the workflow sends an e-mail to the approver. I've noticed that the pending workflows only "wake up" and send their e-mails if I kick off a new request (i.e. new workflow instance). I assume that in starting a new flow something checks the instance store for instances that are due to resume and resumes them. I've only just noticed the problem because I was previously testing with delays that were just a few minutes rather than days. I haven't tried it on IIS6 yet but I expect it would be the same.
q1) do I need to write a console app or something to periodically check and resume the flows and if so can someone advise how to do it? Or have I just done something wrong?
q2) Assuming that the answer to Q1 is "yes, you need to write something" if I was to use IIS7 and AppFabric (which may be possible) would the sleep/resume just work without me having to write any code to check and resume the flows? i.e. just deploy the workflow service into AppFabric and it works?
Thanks in advance.
The answer to q1 is yes. After an IIS AppDomain recycles it is not restarted until there is an external request for it. As a result the WorkflowServiceHost is not active and expired Delay activities will not be resumed. With versions of IIS before 7 you need to create an external request to make sure the WorkflowServiceHost is available. The easiest way of doing so is just have a windows service periodically retrieve the WSDL page.
If your upgrade to IIS7 and AppFabric you can configure a service to automatically start as soon as IIS is running and that will take care of the same problem. I would prefer this option as AppFabric gives you a lot of extra benefits like tracking.
Yes Windows Server AppFabric's Workflow Management Service will wake up workflows with pending timers. You get this for free as well as other goodies.

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.