【发布时间】:2015-07-20 15:41:02
【问题描述】:
我有一个专门的过滤器索引。
那里有3000 查询。这是一个典型的查询:
{
"index": "articles_percolators",
"type": ".percolator",
"body": {
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"query_string": {
"fields": [
"title"
],
"query": "Cities|urban|urbanization",
"allow_leading_wildcard": false
}
},
{
"query_string": {
"fields": [
"content"
],
"query": "Cities|urban|urbanization",
"allow_leading_wildcard": false
}
},
{
"query_string": {
"fields": [
"url"
],
"query": "Cities|urban|urbanization",
"allow_leading_wildcard": false
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"terms": {
"feed_id": [
3215,
3216,
10674,
26041
]
}
}
]
}
}
}
},
"sort": {
"date": {
"order": "desc"
}
},
"fields": [
"_id"
]
},
"id": "562"
}
映射(PHP 数组)。为简洁起见,过滤器、分析器和标记器被排除在外:
'index' => 'articles_percolators',
'body' => [
'settings' => [
'number_of_shards' => 8,
'number_of_replicas' => 0,
'refresh_interval' => -1,
'analysis' => [
'filter' => [
],
'analyzer' => [
],
'tokenizer'=> [
]
]
],
'mappings' => [
'article' => [
'_source' => ['enabled' => false],
'_all' => ['enabled' => false],
'_analyzer' => ['path' => 'lang_analyzer'],
'properties' => [
'lang_analyzer' => [
'type' => 'string',
'doc_values' => true,
'store' => false,
'index' => 'no'
],
'date' => [
'type' => 'date',
'doc_values' => true
],
'feed_id' => [
'type' => 'integer'
],
'feed_subscribers' => [
'type' => 'integer'
],
'feed_canonical' => [
'type' => 'boolean'
],
'title' => [
'type' => 'string',
'store' => false,
],
'content' => [
'type' => 'string',
'store' => false,
],
'url' => [
'type' => 'string',
'analyzer' => 'simple',
'store' => false
]
]
]
]
]
然后我一次将文档发送到mpercolate API,100。这是mpercolate 请求的一部分(1 个文档):
{
"percolate": {
"index": "articles_percolators",
"type": "article"
}
},
{
"doc": {
"title": "Win a Bench Full of Test Equipment",
"url": "\/document.asp",
"content": "Keysight Technologies is giving away a bench full of general-purpose test equipment.",
"date": 1421194639401,
"feed_id": 12240778,
"feed_subscribers": 52631,
"feed_canonical": 1,
"lang_analyzer": "en_analyzer"
}
}
100 文章在我的 MacBook Pro 2.4 GHz Intel Core i7(4 核,8 带 HT)上以 ~1 second 处理,所有内核最多:
这对我来说似乎相当慢,但我没有可比较的基础。
我有一个具有相同映射(但有 6 个分片)的常规索引,有超过 30 亿个文档(仍然)存在于具有24 core Xeon 和128GB RAM 的单个服务器上。此类查询在不到100ms(在热服务器上)中搜索整个索引。
我的设置是否存在明显错误,是否有其他人对渗滤器的性能进行了基准测试?我没有在网上找到任何关于此的其他内容......
我的 ES 版本是 1.4.2,具有默认配置,工作负载完全受 CPU 限制。
编辑
因为John Petrone's 评论关于在生产环境中进行测试是正确的,所以我在生产环境中使用的相同 24 核 Xeon 上进行了测试。即使不是更糟,渗透指数为 8 的碎片索引的结果也是相同的。时间在 1 秒到 1.2 秒之间,而网络延迟低于我的笔记本电脑。
这可能是因为 Xeon 的每个内核的时钟速度较慢 - 2.0GHz 与 i7 的 2.4Ghz 相比。
这导致 CPU 利用率几乎恒定在 800% 左右:
然后我用 24 个分片重新创建了索引,时间已降至每 100 个文档 0.8 秒,但 CPU 时间增加了一倍多:
我每秒有大约 100 个文档的恒定流,并且将来查询的数量会增加,所以这对我来说有点担心。
【问题讨论】:
-
有没有办法分析查询或请求,查看正在发生的事情以及消耗 CPU 周期的内容,例如 MySQL 的 EXPLAIN?
-
2年后情况如何?
标签: elasticsearch