We were stuck with a weird issue. Our ASP.NET web app was crashing for some reason and the event log only displayed Stackoverflow exception. We want to narrow down the reason for the crash and since stackoverflow exceptions are easy to debug (even crash dumps didnt give help much), we wanted our app to shut down the moment first time this excepton occured. Application pool recycles itself if it crashes due to an error. But it stops if the number of crashes exceeds a certain value within a certain time interval.
You can do this by changing Rapid Fail Protection options in the application pool advanced settings. See the image below:
Failure interval in minutes is the time within which "x" number of crashes would cause the app pool to stop. Maximum failures is that number "x", the number of failures within a certain time interval which would cause the app pool to stop.
By default both these values are set to 5 (which means app pool will stop if it crashes 5 times within 5 min).
We changed these values to 50 (time interval) and 1 (no of crashes) respectively so that our app pool should stop the moment first crash occured. This allowed us to keep changing code to see what was causing the site to throw a 503 error.