Sunday, October 14, 2007

When a Cache is Not a Cache

The first problem area I had with our project was when we made the Internet-facing site live. We set up output caching and BLOB caching to cache pretty much all of the site. We also setup the Object cache. We figured we had our bases covered because we tried these things on our development site and they increased page load time significantly.

The site went live and it was doing well for most of the morning when 11 o'clock hit and we now had 3 time zones worth of people hitting the site. We suddenly noticed that the processor was getting pegged at 100% and that the amount of memory used was increasing quite quickly.

After spending a week looking at the performance monitor for various counters and checking Microsoft documentation, we had finally figured out that some of the memory leak was due to not cleaning up SPRequest objects. We cleaned up all of our custom code and this improved the site marginally. We also began tweaking the output cache to find a good balance and settled on 4 hours for pages to be cached. The BLOB cache works wonderfully, it caches images, and other Binary Large Objects. It is awesome to see whole pages load without images filtering in one at a time.

The site was still not running quite right and we had noticed on the object cache counter that objects were being thrown out of the cache as soon as they were put in. I began monitoring the SharePoint logs and found that pages were being invalidated and thrown out of the cache. So this led to a call to Microsoft. After the same questions and sending them an SPSReports CAB file, they came back saying that the object cache does not cache custom code objects. This didn't fare well as almost every page of our site has custom code on it. After looking over the options and Microsoft telling me that there was no expected date for a fix, we decided to monitor the site some more and noticed that the page output was still being cached, so the object caching not storing our code was only going to be a problem for the first person to hit that page. We decided that this was acceptable performance for the site.

In the next few blog posts I will explain the various types of caching and how they can help your MOSS site's performance and scalability (especially if an Internet-facing site).

2 comments:

  1. "I began monitoring the SharePoint logs and found that pages were being invalidated and thrown out of the cache. So this led to a call to Microsoft. After the same questions and sending them an SPSReports CAB file, they came back saying that the object cache does not cache custom code objects."

    I do not understand why pages would come out of *page output cache* due to what is in the object cache. Is this just badly written?

    ReplyDelete
  2. Mark,

    Microsoft is right that custom code objects will not be cached in the object cache. What I have found in the SharePoint logs is similar to what you have found in that there would be entries that said invalidating a page from the cache. Although I have not found a definitive answer for these entries they lead me to believe that as new objects are being cached, older ones are being thrown out. For example our settings cache items for 4 hours. After that time they are thrown out of the cache and would need to be rebuilt. I believe the entries for invalidated cache are those objects being thrown out due to a time limit or to changes in the page. If the page changes it would rebuild it and store it in the cache again.

    Once again, I am not positive on this theory, but I have not run into any issues with performance due to those messages. I believe the SharePoint logs are sometimes too descriptive in that they log every action SharePoint takes.

    You could verify some of this by checking the setting to include the cache information in the rendered page and see what time the page was cached and make sure it stays cached for the length of time that you have set.

    Michael

    ReplyDelete