Partager via


Too Frequent Application Pool recycling in IIS can lead to unexpected issues

Issue:

=============================

We were getting following errors while browsing our asp.net web application in different websites.

1. "Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500"

2. An error has occurred in the application. Please contact administrator.

   Object reference not set to an instance of an object.

3. Error: The request data is invalid. Please try creating/editing the request again.

4. An unexpected condition has occurred in a application. The information contained here should be made available to your site administrative staff.

Request details Url=https://URL/Page.aspx (method=POST)

5. Event ID; 2262, ISAPI 'c;\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll' reported itself as unhealthy for the following reason: 'Deadlock detected'.

Resolution:

=================================

We found that all the errors were because of one factor. Once again event logs helped and we found that the worker process was recycling very quickly. They looked similar to

"A worker process with process ID IDNumber serving application pool AppPoolName has requested a recycle because it reached its scheduled recycle time."

"A worker process with process ID IDNumber serving application pool AppPoolName has requested a recycle because it reached its private bytes memory limit."

The 500 errors that we got would typically request when the worker process is exiting and a request reaches it. We looked at the Application pool properties in IIS and found that the property “Recycle worker process in minutes” was set to 1 hr. We also found that the value of Maximum used memory (in MB) was set to 100 MB. Due to these two factors, the worker process was recycling very quickly and resulted in all the above errors intermittently.

We suggested to uncheck the settings and as expected, this action fixed the issue.

If we choose to recycle the application, one may choose a specific time by using the option “recycle worker processes at following times”. For the second setting (Maximum used Memory), it is generally good to have the option unchecked unless we have a serious memory leak problem.