英文:
Timeout/Cancel long running elasticsearch query
问题
如何有效设置 Elasticsearch 中昂贵查询的超时/取消?
ES 集群的数据存储容量约为 100T,其中已使用了 60T。分片大小为 20G。
search.default_search_timeout
和 search.cancel_after_time_interval
已设置为 1 秒,但未生效。
英文:
What is a good way to timeout/cancel a expensive query in elasticsearch?
ES Cluster' data storage capacity is about 100T off which 60T is used. Shard size is 20G.
search.default_search_timeout
and search.cancel_after_time_interval
were set to 1sec and didn't work.
答案1
得分: 1
The search timeout can be configurable at query time and also it can be configurable via cluster settings to apply all your searches.
GET test_index/_search
{
"timeout": "60s",
"query": {},
"aggs": {}
}
PUT /_cluster/settings
{
"persistent": {
"search.default_search_timeout": "60s"
}
}
Note: The query timeout is not guaranteed. In some cases (especially in very large indices) the timeout operation may fail. To set a cluster-wide default timeout for all search requests, configure search.default_search_timeout
using the cluster settings API. This global timeout duration is used if no timeout argument is passed in the request. If the global search timeout expires before the search request finishes, the request is canceled using task cancellation. The search.default_search_timeout
setting defaults to -1 (no timeout).
please note that the timeout is per shard not per request
As you experienced it's not guaranteed the timeout. To protect your cluster and drop heavy queries you need to use an external application. I recommend you check the Search gateway.
英文:
The search timeout can be configurable at query time and also it can be configurable via cluster settings to apply all your searches.
GET test_index/_search
{
"timeout": "60s",
"query": {},
"aggs": {}
}
PUT /_cluster/settings
{
"persistent": {
"search.default_search_timeout": "60s"
}
}
Note: The query timeout is not guaranteed. In some cases (especially in very large indices) the timeout operation may fail.
To set a cluster-wide default timeout for all search requests, configure search.default_search_timeout using the cluster settings API. This global timeout duration is used if no timeout argument is passed in the request. If the global search timeout expires before the search request finishes, the request is cancelled using task cancellation. The search.default_search_timeout setting defaults to -1 (no timeout).
> please note that the timeout is per shard not per request
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html
As you experienced it's not guaranteed the timeout. To protect your cluster and drop heavy queries you need to use an external application. I recommend you check the Search gateway.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论