繁体   English   中英

Elasticsearch性能分析

[英]Elasticsearch Performance Analysis

我们目前正在评估Elasticsearch作为我们的Analytics解决方案。 主要驱动因素是,一旦将数据填充到Elasticsearch中,Kibana便会免费提供报告。

在采用它之前,我受命对工具进行性能分析。

主要要求是支持500 evt / sec的PUT速率。

我目前从一个小的设置开始,如下所示,目的是在将其上传到更严格的实验室之前先了解一下API。

我的策略基本上是,遍历与我需要的格式相对应的分析CSV并将其放入elasticsearch。 我没有使用批量API,因为实际上事件不会以批量方式到达。

以下是执行此操作的主要代码:

        // Created once, used for creating a JSON from a bean
        ObjectMapper mapper = new ObjectMapper();

        // Creating a measurement for checking the count of sent events vs
        // ES stored events
        AnalyticsMetrics metrics = new AnalyticsMetrics();
        metrics.startRecording();

        File dir = new File(mFolder);
        for (File file : dir.listFiles()) {

            CSVReader reader = new CSVReader(new FileReader(file.getAbsolutePath()), '|');
            String [] nextLine;
            while ((nextLine = reader.readNext()) != null) {
                AnalyticRecord record = new AnalyticRecord();
                record.serializeLine(nextLine);

                // Generate json
                String json = mapper.writeValueAsString(record);

                IndexResponse response = mClient.getClient().prepareIndex("sdk_sync_log", "sdk_sync")
                        .setSource(json)
                        .execute()
                        .actionGet();

                // Recording Metrics
                metrics.sent();

            }
        }

        metrics.stopRecording();

        return metrics;

我有以下问题:

  1. 如何通过API知道所有请求均已完成并将数据保存到Elasticsearch中? 我可以查询Elasticsearch以获取特定索引中的对象数,但是这样做本身就是一个新的性能因素,因此我取消了此选项。
  2. 是上述将对象插入Elasticsearch的最快方法,还是我可以做其他优化。 请记住,批量API暂时不可用。

提前谢谢。

PS:我在客户端和服务器上使用的Elasticsearch版本是1.0.0。

  1. Elasticsearch索引响应具有isCreated()方法,如果文档是新文档,则返回true如果文档已更新,则返回false ,可用于查看文档是否已成功插入/更新。

  2. 如果不能选择批量索引,则可以对其他领域进行调整以提高性能,例如

    • 使用index.refresh_interval增加索引刷新间隔
    • 通过将index.number_of_replicas设置为0来禁用副本
    • 如果不需要_source_all字段,请禁用它们。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM