on application pool my .net core(3.1) application suddenly shutdown(in production server), I often get the following entry in event log Failed to gracefully shutdown application 'MACHINE/WEBROOT/APPHOST/SITEName'.
Related
I have an ASP.NET Core app — a RESTful API with websocket functionality through SignalR.
We have an issue when the application pool is recycled automatically every 29 hours - sometimes (rarely) it doesn't recover. Even manually, I can't restart the application pool.
Yesterday the only thing that helped was restarting the w3 publishing service.
By looking through logs I can see one moment the server responds nicely and fast with code 200 responses, then next it's all code 400 responses (?) and shortly thereafter 503.
Any idea what could be preventing it from recycling. The event log states in order:
A worker process with process id of '29752' serving application pool 'DefaultAppPool' has requested a recycle because the worker process reached its allowed processing time limit.
A worker process '29752' serving application pool 'DefaultAppPool' failed to stop a listener channel for protocol 'http' in the allotted time. The data field contains the error number.
Binary data:
In Words
0000: 800705B4
A process serving application pool 'DefaultAppPool' exceeded time limits during shut down. The process id was '29752'.
I'm hosting my web application on azure web app by using suave and following the recommended guide.
My app was running like a charm until some days ago something went horribly wrong:
The process threw and exception and crashed, but HttpPlatformHandler failed to restart the process and the eventlog was full of the following errors:
Process '0' failed to start. Port = 30590, Error Code = '-2147023897'.
and
Maximum rapid fail count per minute of '10' exceeded.
I got this error for hours and in this time my application responded with
502: The specified CGI application encountered an error and the server terminated the process.
The only way to solve the problem was to manually restart the web application.
I don't understand why the platform handler was unable to restart the process.
A successful start looks like the following:
Process '5516' started successfully and is listening on port '29676'.
So what's up with this Process '0'?
I have process named agent.exe, my app pool runs 2 instances of this process.
When recycle my AppPool then most of the times it works and those 2 instances are shutting down and 2 new instances are up.
but sometimes when I recycle my 2 old instances aren't shutting down while my 2 new instances are up and working, so I can have 4,6 and even more instances running.
Can I see why the instances aren't been recycled? I only found this http://technet.microsoft.com/en-us/library/cc735206(v=ws.10).aspx, but those are only informative logs and I can't see errors in them.
Does anyone know way to see recycling errors logs?
My server is Windows 2003 and I'm running IIS6.
It should be noted that there is no connection to "Overlapping recycling" because the instances don't shutting down at all.
thanks.
I found the following logs that can use to identify App Pool recycle errors:
AppPoolRecycleTime - Logs event on time-based recycles.
AppPoolRecycleRequests - Logs event on number of request-based
recycles. AppPoolRecycleSchedule - Logs event on schedule-based
recycless. AppPoolRecycleMemory - Logs event on memory-based
recycle. AppPoolRecycleIsapiUnhealthy - Logs event when worker
processes request recycles because an ISAPI reported unhealthy.
AppPoolRecycleOnDemand - Logs event when an administrator requests a
recycle of all processes in the application pool.
AppPoolRecycleConfigChange - Logs an event if an application pool is
recycled because one of the application pool properties that requires
a recycle to take effect has changed. AppPoolRecyclePrivateMemory -
Logs an event if an application pool is recycled based on private
memory.
taken from here:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/87892589-4eda-4003-b4ac-3879eac4bf48.mspx?mfr=true
I have some questions about IIS application pool configuration.
I know that idleTimeout specifies how long a worker process should run idle if no new requests are received and the worker process is not processing requests. After the allocated time passes, the worker process should request that it be shut down by the WWW service (taken from here). My question is when and how the worker process starts when a request arrives after it shut down?
Other question is what is the difference between application pool recycling and between shut down? Does it better to recycke instead of shut down and then start again?
When and How worker process starts? When a new request comes in IIS spins a new process for the app pool your website is running under.
The difference between shutting down and recycle is that during a recycle a new process is started for the app pool in parallel, while the existing process is still serving an existing request. Any new requests that come in are handled by the new process. So in effect you do not loose any request that come in and any existing requests are not prematurely dropped. In a shutdown, you will loose the requests while the app is down.
To see this live in action - open task manager, select processes tab and see IIS spin up the app pool processes and notice the behavior between a shutdown and recycle. During a recycle for a brief moment you will see two processes for the same app pool.
See this video for a better understanding : http://dotnetslackers.com/articles/iis/IIS-Overlapping-App-Pools-Week-16.aspx
according to the the IIS documentation the rapid fail protection once activated leads to the deactivation of an application pool if a "failure" occurs. However, I could not find the definition of the "failure" case. In my web application I have a special exception that I would like the IIS to consider it as a "failure".
Does anyone have an idea? Thanks
This appears to have a list, for Server 2003 at least: http://web.archive.org/web/20130511004652/http://technet.microsoft.com/en-us/library/cc787273(WS.10).aspx
The WWW service shuts down an application pool whenever a worker
process in the application pool fails often enough to equal or exceed
the Rapid-Fail Protection (RFP) interval time window (for example:
five failures in five minutes). The WWW service detects failure
whenever:
A worker process does not start within the startup time limit.
A worker process does not shut down within the shutdown time limit.
A worker process shuts itself down because of a fatal error and sends
the WWW service an error code.
A worker process fails to respond to a ping message.
The WWW service detects that a worker process is sending non-standard
communications (the worker process may have been taken over).
(updated with archive.org to fix broken link, and replicated detail here)
The documentation for configuring rapid fail protection alludes to a "failure" meaning a worker process crash.
Through experimentation I've noticed that you should expect something like the following in Windows Event Application Logs for a w3wp.exe crash:
An unhandled exception occurred and the process was terminated.
Application ID: /LM/W3SVC/1/ROOT
Process ID: 2628
Exception: System.SomeUnhandledException
Indeed with rapid fail protection enabled with the default configuration, 5 such events within 5 minutes of each other cause the application pool to stop, and you'll see a further Windows Event Application Log similar to:
Application pool 'my-test-application-pool' is being automatically
disabled due to a series of failures in the process(es) serving that
application pool.