Typically a bottleneck in performance occur while retrieving and writing application data that resides in database and application data in session states. We can use the various levels of caching in SharePoint 2010 to increase the performance of SharePoint applications as written in the previous article. In-memory distributed caching is a form of caching that allows the cache to span multiple servers so that it can grow in size and in transactional capacity.
In SharePoint 2013 there is a new service called Distributed Cache. The Distributed Cache service is built on Windows Server AppFabric, which implements the AppFabric Caching service. Windows Server AppFabric installs with the prerequisites for SharePoint Server 2013.
The Distributed Cache service provides in-memory caching services and does not have a dependency on databases for several features in SharePoint Server 2013. Some of the features that use the Distributed Cache service include:
- OneNote client access
- Security Trimming
- Page load performance
When the service is enabled, these features use the Distributed Cache for quick data retrieval. Blob Cache and Output Cache do not use a distributed caching service since these types of cache exist on each Web Front End server in the farm.
Any server in the farm running the Distributed Cache service is known as a cache host. A cache cluster is the group of all cache hosts in a SharePoint Server 2013 farm. A cache host joins a cache cluster when a new application server running the Distributed Cache service is added to the farm. When using a cache cluster, the Distributed Cache spans all application servers and creates one cache in the server farm. The total cache size is the sum of the memory allocated to the Distributed Cache service on each of the cache hosts.
The Distributed Cache service can run in dedicated or collocated mode. When running in dedicated mode, the Distributed Cache service is started and all other services are stopped on the server. In collocated mode, the Distributed Cache service is running along with other services on the server.
Various caches that depend on the Distributed Cache service
The Following are the SPDistributedCacheContainerType enumerations to set or clear the distributed cache settings. The core API has namespace Microsoft.SharePoint.DistributedCaching.Utilities.
- The feed queries the Last Modified Time Cache to retrieve time stamp information and metadata of recent activities.
- This information is then used as input to query the Feed Cache to retrieve activity data.
- The requested feed is then constructed by using the activity data retrieved from the Feed Cache.
For each entity, the Feed Cache assigns a portion of memory known as a cache bucket to store recent activity data for that entity. Entities include users, tags, sites, and documents. Cache buckets only store recent activities. Many cache buckets will be empty because not all entities will have recent activities. By default, recent activities are kept for seven days.
Points to be noted
- Remote Registry Access and Firewall : You may experience this issue if you have firewall enabled and there is an issue for remote registry access between the SharePoint Servers. This means, we must ensure that the "remote registry service" need to be started in all SharePoint Servers before connecting to the SharePoint farm to configure the AppFabric Cache. If you have a firewall then further configurations may be needed as it may block the connection.
- Maximum Memory Allocation for Cache : A minimum of 8 GB and maximum of 16 GB can be allocated to the Cache. On a server that has more than 16 GB of total physical memory, allocate a maximum of 16 GB of memory to the Distributed Cache service. Also the memory allocation of the cache size must be less than or equal to 40% of the total memory on the server. If you require more memory, you can configure the Distributed Cache service to run on several application servers.
- Memory Allocation : You must ensure that the memory allocation assigned to the Distributed Cache service is the same on all servers that are running the Distributed Cache service. Cached data is stored on one server, not both servers.
- Other Services : Do not run the following services on the same server running the Distributed Cache service: SQL Server, Project Server, Excel Services and Search services.
- Monitor Health : Review SharePoint Server 2013's Health Rules for Distributed Cache service issues.