7

We are having an issue with the app pool resetting in IIS after a media cache folder deletion. This only happens when we have a lot of images (~20 GBs) cached.

Everything I've read says that deleting it is completely safe, and we don't always experience the issue. We sometimes get a buffer overflow error along with the app pool reset, but not always.

We have tried increasing the system filewatcher buffer size to the maximum and doing the cleanup more often, but neither seem to help.

Any ideas why it might be doing this?

2
  • where is your media cache folder located? Is it inside the webroot or outside it?
    – Richard Seal
    Jan 26, 2018 at 20:44
  • It is located inside of the webroot folder. Jan 26, 2018 at 21:01

1 Answer 1

5

The problem you are seeing is a "feature" of IIS that will recycle the application pool if too many files change inside the webroot. This includes that media cache folder. I'm not sure of the actual number of changes that will trigger the restart.

  1. Making any modifications in the Web Application’s Root Directory. This means creating files/subdirectories on the fly can lead to application pool recycling.

ref: https://varunvns.wordpress.com/2011/07/04/application-pool-restarts/

and

ASP.NET 2.0 depends on File Change Notifications (FCN) to see if the application has been updated. Depending on the change the application pool will recycle. If you or your application is adding and removing directories to the application folder, then you will be restarting your application pool every time, so be careful with those temporary files.

What is the purpose of clearing out the media cache folder? If you really need to do that, then maybe batching the delete into smaller chunks at scheduled times would prevent a restart of the application pool.

ref: https://blogs.msdn.microsoft.com/johan/2007/05/16/common-reasons-why-your-application-pool-may-unexpectedly-recycle/

What is the purpose of clearing out the media cache folder? If you really need to do that, then maybe batching the delete into smaller chunks at scheduled times would prevent a restart of the application pool.

2
  • 1
    We figured this might have been the case. We will try moving the media cache folder outside of the webroot. I've accepted this as the answer. Jan 26, 2018 at 21:34
  • 5
    Note that deleting files from the Media Cache folder will require Sitecore to (obviously) recreate the cache the next time that item is requested, causing a round trip to the database to fetch the media blob + resize as required rather than serving directly from disk. There is an associated performance cost to this. Sitecore also already has a CleanupAgent which deletes files older 90 days by default (check the configs to confirm).
    – jammykam
    Jan 26, 2018 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.