将 CSV 内存中读取缓存与 Azure Stack HCI 配合使用Use the CSV in-memory read cache with Azure Stack HCI

适用于:Azure Stack HCI 版本 20H2;Windows Server 2019Applies to: Azure Stack HCI, version 20H2; Windows Server 2019

本主题介绍如何通过缓存频繁读取的内容来使用系统内存提高 Azure Stack HCI 的性能。This topic describes how to use system memory to boost the performance of Azure Stack HCI by caching frequent reads. 写入内容不能缓存在内存中。Writes cannot be cached in memory.

Azure Stack HCI 与群集共享卷 (CSV) 内存中读取缓存兼容。Azure Stack HCI is compatible with the Cluster Shared Volume (CSV) in-memory read cache. 对于使用未缓冲 I/O 访问 VHD 或 VHDX 文件的应用程序(如 Hyper-V),使用系统内存缓存读取可以性能。Using system memory to cache reads can improve performance for applications like Hyper-V, which uses unbuffered I/O to access VHD or VHDX files. (未缓冲 I/O 是未由 Windows 缓存管理器缓存的任何操作。)(Unbuffered I/Os are any operations that are not cached by the Windows Cache Manager.)

由于内存中缓存是服务器本地缓存,因此它可改善数据区域:最近读取会缓存在运行虚拟机的相同主机上的内存中,从而减少通过网络进行读取的频率。Because the in-memory cache is server-local, it improves data locality: recent reads are cached in memory on the same host where the virtual machine is running, reducing how often reads go over the network. 这可实现更低的延迟和更好的存储性能。This results in lower latency and better storage performance.

请注意,CSV 内存中读取缓存与 Azure Stack HCI 中的存储池缓存不同。Note that the CSV in-memory read cache is different from the storage pool cache in Azure Stack HCI.

规划注意事项Planning considerations

内存中读取缓存对于读取密集型工作负载(如虚拟桌面基础结构 (VDI))最有效。The in-memory read cache is most effective for read-intensive workloads, such as Virtual Desktop Infrastructure (VDI). 相反,如果工作负载是极端的写入密集型,则缓存引入的开销可能会高于获得的价值,因此应禁用。Conversely, if the workload is extremely write-intensive, the cache may introduce more overhead than value and should be disabled.

可以将多达 80% 的总物理内存用于 CSV 内存中读取缓存。You can use up to 80% of total physical memory for the CSV in-memory read cache. 请注意为虚拟机留出足够的内存!Be careful to leave enough memory for your virtual machines!

备注

某些微基准工具(如 DISKSPD 和 VM Fleet)在启用了 CSV 内存中读取缓存时得到的结果可能比未启用时更差。Certain microbenchmarking tools like DISKSPD and VM Fleet may produce worse results with the CSV in-memory read cache enabled than without it. 默认情况下,VM Fleet 会为每个虚拟机创建一个 10 GiB VHDX(对于 100 个 VM 总共将近 1 TiB),然后对它们执行均匀随机读取和写入。By default VM Fleet creates one 10 GiB VHDX per virtual machine – approximately 1 TiB total for 100 VMs – and then performs uniformly random reads and writes to them. 与实际工作负载不同,读取不遵循任何可预测或重复的模式,因此内存中缓存不起作用,只会产生开销。Unlike real workloads, the reads don't follow any predictable or repetitive pattern, so the in-memory cache is not effective and just incurs overhead.

配置内存中读取缓存Configuring the in-memory read cache

CSV 内存中读取缓存在具有相同功能的 Azure Stack HCI、Windows Server 2019 和 Windows Server 2016 中可用。The CSV in-memory read cache is available in Azure Stack HCI, Windows Server 2019, and Windows Server 2016 with the same functionality. 在 Azure Stack HCI 和 Windows Server 2019 中,它在默认情况下处于打开状态,分配有 1 GiB。In Azure Stack HCI and Windows Server 2019, it's on by default with 1 gibibyte (GiB) allocated. 在 Windows Server 2016 中,它在默认情况下处于关闭状态。In Windows Server 2016, it's off by default.

OS 版本OS version 默认 CSV 缓存大小Default CSV cache size
Azure Stack HCIAzure Stack HCI 1 GiB1 GiB
Windows Server 2019Windows Server 2019 1 GiB1 GiB
Windows Server 2016Windows Server 2016 0(禁用)0 (disabled)

若要使用 Windows Admin Center 来配置缓存,请在左侧“工具”菜单的最底部选择“设置”。To configure the cache using Windows Admin Center, select Settings at the very bottom of the Tools menu on the left. 然后转到“存储”>“内存中缓存”。Then go to Storage > In-memory cache. 可以使用复选框来启用或禁用缓存,还可以指定每个服务器要分配给缓存的最大内存。A checkbox enables or disables the cache, and you can also specify the maximum memory per server to be allocated to the cache. 进行更改后,请务必单击页面底部的“保存”。Be sure to click Save at the bottom of the page after making your changes.

若要使用 PowerShell 查看分配的内存量,请运行:To see how much memory is allocated using PowerShell, run:

(Get-Cluster).BlockCacheSize

返回的值针对每台服务器,以 MiB 为单位。The value returned is in mebibytes (MiB) per server. 例如,1024 表示 1 GiB。For example, 1024 represents 1 GiB.

若要更改分配的内存量,请使用 PowerShell 修改此值。To change how much memory is allocated, modify this value using PowerShell. 例如,若要为每台服务器分配 2 GiB,请运行:For example, to allocate 2 GiB per server, run:

(Get-Cluster).BlockCacheSize = 2048

若要使更改立即生效,请暂停,然后恢复 CSV 卷,或在服务器之间移动它们。For changes to take effect immediately, pause then resume your CSV volumes, or move them between servers. 例如,使用此 PowerShell 片段将每个 CSV 移动到另一个服务器节点,并再次返回:For example, use this PowerShell fragment to move each CSV to another server node and back again:

Get-ClusterSharedVolume | ForEach {
    $Owner = $_.OwnerNode
    $_ | Move-ClusterSharedVolume
    $_ | Move-ClusterSharedVolume -Node $Owner
}

后续步骤Next steps

如需相关信息,另请参阅:For related information, see also: