我正在通过发送查询来对 Elastic Search 进行压力测试,但担心响应会被缓存。测试 Elastic Search 时如何关闭缓存?
最佳答案
在我回答之前,我同意对问题的评论的免责声明,禁用缓存并不是对 Elasticsearch 进行压力测试的最佳方式。同时使用代表您的生产查询集的查询和事件索引来命中它,将是查看 ES 在负载下如何响应的更好方法。
但是,要回答您的问题并指出一些注意事项:
您可以在两次运行之间清除缓存:
The clear cache API allows to clear either all caches or specific cached associated with one ore more indices.
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html
您可以通过设置关闭过滤器缓存 index.cache.filter.type 为 none - 这将阻止过滤结果 从被缓存:
http://elasticsearch-users.115913.n3.nabble.com/Disable-cache-td3825105.html
http://elasticsearch-users.115913.n3.nabble.com/Disabling-cache-td3201850.html
您可以更改字段数据缓存的设置 - 但是我 不知道如果将其设置为零会发生什么:
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-fielddata.html
不过,总的来说,请记住 Elasticsearch 非常重要 使用 native 操作系统文件系统缓存,所以很多“缓存”是 发生在 ES 的控制之外:
https://blog.codecentric.de/en/2014/05/elasticsearch-indexing-performance-cheatsheet/
关于elasticsearch - 测试 Elastic Search 时如何关闭缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25212911/