使用 Azure Stack HCI 的 CSV 記憶體中讀取快取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. 使用系統記憶體快取讀取可以改善 Hyper-v 應用程式的效能,這會使用未緩衝的 i/o 來存取 VHD 或 VHDX 檔案。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.

您最多可以針對 CSV 記憶體中讀取快取使用80% 的總實體記憶體。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!

注意

某些 microbenchmarking 工具(例如 DISKSPD 和 VM 車隊 )可能會產生較差的結果,並啟用 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 車隊會為每個虛擬機器建立 1 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 (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: