SharePoint 2013 SPDistributedCacheService 是SharePoint server 2013引入的一种缓存机制,它通常用于以下功能的缓存:
- Newsfeeds
- Authentication
- OneNote client access
- Security Trimming
- Page load performance (直接影响页面加载和反应速度)
有些Cache 是不通过
SPDistributedCacheService 缓存的,例如:
- Blob Cache (图片,脚本等),它们只缓存在WEF server 上
- Output cache (Asp.net 页面缓存), 也只缓存在WEF server 上
其实
SPDistributedCacheService 是利用 Window server 2012 的AppFabricCachingService来构建的分布式缓存系统。
安装 SharePoint 2013 准备套件时会自动安装
AppFabricCachingService。
以下是
AppFabricCachingService的逻辑架构图:
SharePoint 2013 中, Cluster configuration 存放在 SharePoint_Config 数据库中, Cache server 可以是任意WEF server 和 app server
下面介绍如何配置
SPDistributedCacheService:
1. 在任意想部署Cache的WEF 或 App server 上依次运行下列 SharePoint power shell
命令
a. 倒入 power shell 网络安全模块
Import-ModuleNetSecurity
b. 开启防火墙规则
Set-NetFirewallRule-DisplayName "File and Printer Sharing (Echo Request -ICMPv4-In)" -Enabled True
c. 将本机加入到 Cache host cluster (集群)
Add-SPDistributedCacheServiceInstance
4. 将本机缓存大小设置为 2G, 系统默认为本机内存的 5%
Update-SPDistributedCacheSize-CacheSizeInMB 2048
注意:单机机缓存大小不要超过 16 G,且不要超出本机总内存的40%
2. 运行以下命令验证配置结果
a. Get-CacheHost
b. Get-CacheHostConfig -ComputerName rtatstuswspapp2 –CachePort 22233
通过笔者的测试,配置了SPDistributedCacheService 之后,叶面加载效率大概提升10~20 倍。