Architectural Solution - Distributed Caching to improve Performance and Scalability – Part 2

In the first part of this article series, I explained the first approach in implementing distributed caching within SharePoint farm. Here goes the next approach.

Service applications have always been my favourite to implement distributed architecture that too within SharePoint farm. Yes, another approach in achieving distributed caching is using Service Application.

Distributed Caching using Service Application

Fig. 1 depicts the deployment architecture diagram with Application server hosting the custom service application.

Fig. 1 Custom Caching service Application in SharePoint farm

I am not going to walk through the entire code to create custom service application here. You can refer to the Andrew Connell’s blog Building Customer Service Applications for the Right Situations (Real World SharePoint 2010) to create service application step by step.

The service contract - IService, Caching Object - MyCache implementation will be same as I explained in the first article of this series.

Hosting implementation in this case is little different. Here is the sample code for CachingServiceApplication:

Consuming this custom Caching service is as easy as consuming out of the box SharePoint Service Application. I am not going to add that code here.

Many enterprises have the Application Pool recycle policy. When implementing this approach, it is important to check the recycling policy. However, this is the IIS setting which can be changed for the App Pool hosting the caching service application.


Implementing either of these solutions varies with the farm topology. Mirror and Replicated caching can be achieved using both the approaches. It is all based on the business requirement which caching to be adopted using either of these approaches. It must be noted here that distributed caching adds little overhead to the performance, very obvious one is network latency. But it addresses significantly critical problems as discussed in the first article of this series.

Few things should be taken care of when implementing these solutions. Here are few:

  1. Brush up your WCF skills.
  2. Use correct Object encoding and binding mechanism. This is very important as WCF performance is depends on these factors.
  3. Use appropriate exception policy that is practiced across the Enterprise.
  4. Take all the Thread Safety measures in Caching classes (where objects are cached. MyCache class in these examples).
  5. Use correct compression policy for large object marshalling.