分層儲存的最佳實務Compatible with Milvus 2.6.4+
Milvus 提供分層儲存,協助您有效率地處理大型資料,同時平衡查詢延遲、容量和資源使用。本指南總結了針對典型工作負載的建議配置,並解釋每個調整策略背後的原因。
開始之前
Milvus v2.6.4 或更新版本
QueryNodes 必須有專用的本機資源 (記憶體和磁碟)。共用環境可能會扭曲快取預估,並導致驅逐錯誤判斷。
選擇正確的策略
分層儲存提供彈性的載入與快取策略,可以結合使用以符合您的工作負載。
目標 |
建議重點 |
關鍵機制 |
|---|---|---|
最小化首次查詢延遲 |
預先載入關鍵欄位 |
預熱 |
有效率地處理大型資料 |
按需載入 |
懶惰載入 + 部分載入 |
保持長期穩定 |
防止快取記憶體溢出 |
驅逐 |
平衡效能與容量 |
結合預先載入與動態快取 |
混合配置 |
情況 1:即時、低延遲檢索
何時使用
查詢延遲非常重要(例如即時推薦或搜尋排名)
經常存取核心向量索引和標量篩選器
穩定的效能比啟動速度更重要
建議配置
# milvus.yaml
queryNode:
segcore:
tieredStorage:
warmup:
# scalar field/index warm-up to eliminate first-time latency
scalarField: sync
scalarIndex: sync
# warm-up of vector fields is disabled (if the original vector is not required)
vectorField: disable
# vector indexes warm-up to elminate first-time latenct
vectorIndex: sync
# enable cache eviction, and also turn on background asynchronous eviction
# to reduce the triggering of synchronous eviction.
evictionEnabled: true
backgroundEvictionEnabled: true
memoryLowWatermarkRatio: 0.75
memoryHighWatermarkRatio: 0.8
diskLowWatermarkRatio: 0.75
diskHighWatermarkRatio: 0.8
# no expiration time, which avoids frequent reloading
cacheTtl: 0
理由
暖機可消除高頻率標量表和向量索引的首次延遲。
背景驅逐可維持穩定的快取記憶體壓力,而不會阻塞查詢。
停用快取 TTL 可避免熱資料不必要的重新載入。
情況 2:離線、批次分析
何時使用
查詢延遲容忍度高
工作負載涉及大量資料集或許多區段
容量和吞吐量優先於回應能力
建議配置
# milvus.yaml
queryNode:
segcore:
tieredStorage:
enabled: true
warmup:
# disable scalar field/index warm-up to speed up loading
scalarField: disable
scalarIndex: disable
# disable vector field/index warm-up to speed up loading
vectorField: disable
vectorIndex: disable
# enable cache eviction, and also turn on background asynchronous eviction
# to reduce the triggering of synchronous eviction.
evictionEnabled: true
backgroundEvictionEnabled: true
memoryLowWatermarkRatio: 0.7
memoryHighWatermarkRatio: 0.85
diskLowWatermarkRatio: 0.7
diskHighWatermarkRatio: 0.85
# use 1 day expiration to clean unused cache
cacheTtl: 86400
理由
初始化許多區段時,停用暖機可加速啟動。
較高的水印可讓快取記憶體使用更密集,提高總負載容量。
快取記憶體 TTL 會自動清除未使用的資料,以釋放本機空間。
情況 3:混合部署 (混合線上 + 離線)
何時使用
單一叢集同時服務線上與分析工作負載
某些資料集需要低延遲,其他資料集則以容量為優先
建議策略
將即時組態套用至延遲敏感的資料集中
將離線配置套用於分析或歸檔資料集
針對每種工作負載類型獨立調整 evictableMemoryCacheRatio、cacheTtl 和 watermark 比率
理據
結合組態可精細控制資源分配。
關鍵資料集可維持低延遲保證,而次級資料集則可處理更多區段和資料量。
其他調整提示
面向 |
建議 |
說明 |
|---|---|---|
預熱範圍 |
只預先載入查詢頻率高的欄位或索引。 |
不必要的預載會增加載入時間和資源使用。 |
驅逐調整 |
從預設水印 (75-80%) 開始,逐步調整。 |
間隙太小會造成頻繁驅逐;間隙太大則會延遲資源釋放。 |
快取 TTL |
對於穩定的熱資料集,請停用;對於動態資料,請啟用 (例如 1-3 天)。 |
防止陳舊快取記憶體累積,同時平衡清理開銷。 |
超量承擔比率 |
除非資源空間很大,否則避免使用 > 0.7 的值。 |
過度的超量提交可能會導致快取記憶體震動和不穩定的延遲。 |
監控 |
追蹤快取點擊率、資源利用率和驅逐頻率。 |
頻繁的冷負載可能表示需要調整暖機或水印。 |