这是进行Elasticsearch性能测试的正确方法吗?

时间:2016-03-04 06:01:41

标签: elasticsearch

根据某些要求,我正在使用2个查询进行性能测试。

以下是我正在使用的硬件/软件环境。

CPU 8core
Memory 16G
OS centOS 7
elasticsearch 2.1
8G memory for ES heap
no swap

要求是

all query response time less 3 seconds.

我使用的地图如下:

"@timestamp": { "index": "not_analyzed", "type": "date","format": "epoch_second"},
"ROUTER" : { "type" : "integer", "index" : "not_analyzed"},
"IN_IFACE" : { "type" : "integer", "index" : "not_analyzed"},
"OUT_IFACE" : { "type" : "integer", "index" : "not_analyzed"},
"SRC_MAC" : { "type" : "long", "index" : "not_analyzed"},
"DST_MAC" : { "type" : "long", "index" : "not_analyzed"},
"IP_PAIRE" : { "type" : "integer", "index" : "not_analyzed"},
"SRC_IP" : { "type" : "ip", "index" : "not_analyzed"},
"DST_IP" : { "type" : "ip", "index" : "not_analyzed"},
"SRC_PORT" : { "type" : "integer", "index" : "not_analyzed"},
"DST_PORT" : { "type" : "integer", "index" : "not_analyzed"},
"VLAN" : { "type" : "integer", "index" : "not_analyzed" },
"PROTOCOL" : { "type" : "string", "index" : "not_analyzed" },
"BYTES" : { "type" : "long", "index" : "not_analyzed" },
"PACKETS" : { "type" : "long", "index" : "not_analyzed" }

查询是:

curl -XPOST "127.0.0.1:9200/sflow_1454256000/sflow/_search?pretty" -d '
{
    "size":0,
    "query": {
        "filtered":{
            "filter":{
                "range": { "@timestamp": {"gte":0,"lte":1554258400}}
            }
        }
    },
  "aggs":
    {
      "SRC_DST":
        {
          "terms": {"script": "[doc.SRC_IP.value, doc.DST_IP.value].join(\"-\")","size": 2,"shard_size":0, "order": {"sum_bits": "desc"}},
          "aggs": { "sum_bits": { "sum": {"field": "BYTES"} } }
        }
    }
}'

curl -XPOST "127.0.0.1:9200/sflow_1454256000/sflow/_search?pretty" -d '
{
    "size":0,
    "query": {
        "filtered":{
            "filter":{
                "range": { "@timestamp": { "gte":0,"lte":1554258400}}
            }
        }
    },
  "aggs":
    {
      "SRC_MAC":
        {
          "terms": {"field":"SRC_MAC", "size": 3,"shard_size":0, "order": {"sum_bits": "desc"}},
          "aggs": { "sum_bits": { "sum": {"field": "BYTES"} } }
        }
    }
}'

基于官方文档(https://www.elastic.co/guide/en/elasticsearch/guide/current/capacity-planning.html)。首先,您需要找出一个分片的最大文档数。然后找出您的计算机可以容纳多少分片。

以下是我的步骤:

首先,我在节点中只为一个索引使用一个分片。

When the shard have 40 000 docs , response time is 3s.

然后我知道在我的环境中,

如果我希望响应时间在30秒以内,则一个分片的限制为40 000个文档

基于此,我使用多个分片来运行这两个查询。每个分片包含40 000个文档。结果是:

When the number of shards is 2 (each shard have 400 000 docs), the response time is 3s.

然后我得出结论,

我的计算机的限制是2个分片,每个分片有400 000个文档(总计800 000个文档)。如果我希望响应时间在3秒以内。

那么,你能否指出我是否以错误的方式进行测试?

另外,我没有太多使用ES的经验。鉴于我的硬件/软件环境和3s响应要求,这是一个合理的测试结果吗?

------------------ -------------更新

我实际上也做了一些其他测试。我使用5个分片,总共包含900 000个文档。 (每个碎片意味着180 000个文档)。响应时间实际上要好于2个碎片,80万个docs方式。所以我认为这证明了我之前的结论是错误的。但我正在根据官方文档建议进行测试。谁能告诉我为什么?

关于我正在进行测试的官方文档链接。 https://www.elastic.co/guide/en/elasticsearch/guide/current/capacity-planning.html

0 个答案:

没有答案