elasticsearch Elasticsearch高CPU利用率和查询响应时间
我一直在构建一个基于Elasticsearch服务的搜索功能。 我使用的索引映射是:
elasticsearch Elasticsearch高CPU利用率和查询响应时间,
elasticsearch,search,cpu-usage,heap-memory,
elasticsearch,Search,Cpu Usage,Heap Memory,我一直在构建一个基于Elasticsearch服务的搜索功能。 我使用的索引映射是: curl -X PUT "localhost:9200/cast_tag_added" -H 'Content-Type: application/json' -d' { "settings": { "analysis": { "analyzer": { "analyzer_title": { "tokenizer": "tokenizer_title", "
curl -X PUT "localhost:9200/cast_tag_added" -H 'Content-Type: application/json' -d'
{
"settings": {
"analysis": {
"analyzer": {
"analyzer_title": {
"tokenizer": "tokenizer_title",
"filter": [
"lowercase",
"asciifolding",
"trim"
]
},
"tokenizer": {
"tokenizer_title": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 20,
"token_chars": [
"letter",
"digit"
]
}
}
}
},
"mappings": {
"_doc": {
"properties": {
"name": {
"type": "text",
"index": "true",
"analyzer": "analyzer_title",
"search_analyzer": "analyzer_search"
},
"id": {
"type": "long",
"index":"false"
},
"ratings": {
"type" : "double",
"index" : "false"
},
}
}
}
}
}
存储的样本数据为:
{
"name": "Die Hard"
"id": 12345
}
示例查询:
{
"query": {
"function_score": {
"query": {
"bool": {
"should": [{
"match": {
"name": {
"query": "die",
"fuzziness": "AUTO",
"operator": "and",
"boost": 2
}
}
}, {
"match_phrase": {
"name": {
"query": "die",
"boost": 4
}
}
}
},
"field_value_factor": {
"field": "ratings",
"modifier": "log1p",
"missing": 1
}
}
},
"explain" : true
}
}
但是在测试时,我发现查询吞吐量太小(大约24秒),而且查询响应延迟太大(平均约8秒)。我添加了以下设置以获取慢速日志查询:
{
"index.search.slowlog.threshold.query.warn": "0ms",
"index.search.slowlog.threshold.query.info": "0ms",
"index.search.slowlog.threshold.query.debug": "0ms",
"index.search.slowlog.threshold.query.trace": "0ms",
"index.search.slowlog.threshold.fetch.warn": "0ms",
"index.search.slowlog.threshold.fetch.info": "0ms",
"index.search.slowlog.threshold.fetch.debug": "0ms",
"index.search.slowlog.threshold.fetch.trace": "0ms"
}
这给了我所有正在运行的查询的响应时间。
在my-application\u index\u search\u slowlog.log文件中可以看到,每个查询的响应时间都非常短。对于所有查询,它的范围在几微秒到1或2毫秒之间。例如:
[2019-07-16T05:24:06,264][WARN ][index.search.slowlog.query] [node-1] [cast_tag_added][1] took[892micros], took_millis[0], total_hits[676], types[], stats[], search_type[QUERY_THEN_FETCH], total_shards[5], source[<the search query goes here>], id[],
[2019-07-16T05:24:06264][WARN][index.search.slowlog.query][node-1][cast_tag_added][1]拍了[892微米],拍了[0毫秒],点击总数[676],类型[],统计数据[],搜索类型[query_THEN_FETCH],碎片总数[5],来源[],id[],
即使日志中显示的响应时间更短,也无法找出查询响应延迟为何如此之高。还注意到,在elasticsearch服务器上开始测试几秒钟后,CPU利用率峰值高达100%。如果没有索引映射/示例数据/相关查询,我们将无法帮助您。你能为我们提供这些信息吗?添加了样本数据、查询和索引@PierreMalletwe如果没有索引映射/样本数据/相关查询,我们将帮不上你的忙。您能为我们提供这些信息吗?添加了样本数据、查询和索引@PierreMallet