一直以来,ES 堆中常驻内存中占据比重最大是 FST,即 tip(terms index) 文件占据的空间,1TB 索引大约占用2GB 或者更多的内存,因此为了节点稳定运行,业界通常认为一个节点 open 的索引不超过5TB。现在,从 ES 7.3版本开始,将 tip 文件修改为通过 mmap 的方式加载,这使 FST占据的内存从堆内转移到了堆外由操作系统的 pagecache 管理。
参考 ES 7.3 的 release-notes :
Also mmap terms index (.tip) files for hybridfs #43150 (issue: #42838)
现在我们来聊一聊其中的一些细节。
hybridfs 是索引默认的store 类型,他根据操作系统类型自动选择 nio 或者 mmap,那么究竟哪些文件被 mmap 方式打开,手册中说:
Currently only the Lucene term dictionary, norms and doc values files are memory mapped. All other files are opened using Lucene NIOFSDirectory
对应到文件扩展名,就是 nvd(norms),dvd(doc values),tim(term dictionary),tip(term index),cfs(compound)类型的文件使用 mmap 方式加载,其余使用 nio:
1
2
3
4
5
6
7
8
9
10
1