【问题标题】:Settings to improve elasticsearch startup time for unit tests?改善单元测试的弹性搜索启动时间的设置?
【发布时间】:2022-02-06 01:26:46
【问题描述】:

我正在编写启动 elasticsearch 6.4 单节点集群的测试,以确保我的查询按预期运行。集群启动我的测试 RestHighLevelClient 大约需要 10 秒才能 ping 它而不会出现连接错误

Process proc = new ProcessBuilder("elasticsearch").start();
RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(
  new HttpHost('localhost', 9200, 'http'),
  new HttpHost('localhost', 9201, 'http'),

));

// wait for cluster, takes about 10 seconds in practice.
do {
  try {
    client.ping(RequestOptions.DEFAULT);
    break;
  } catch (IOException ex) { }
} while (true);

我可以更改哪些设置来缩短启动时间?

  • 我不需要在测试运行中保留索引,因此可以将索引保存在内存中。我没有看到 memory6.4 store types 中列出
  • 是否存在导致整个集群在不写入磁盘的情况下运行的设置(禁用日志记录、禁用文件存储、禁用 pid/状态)?
  • 集群将是单节点的,因此我可以禁用发现,但我没有找到该设置。编辑:discovery.type=single-node 6.4

【问题讨论】:

  • 我为各种版本找到了一些很好的答案herediscovery.type=single-node 剃掉 4 秒。
  • 我怀疑这在很大程度上是由于庞大的代码库/功能集和 JVM 速度缓慢,并且仅使用 Hotspot 运行,而不是例如格拉尔。这真的很不幸。 PostgreSQL 需要 1 秒才能开始测试。 Elasticsearch 需要 8 秒。
  • @PaulDraper 你在运行什么版本?这里还有一个interesting investigation 测试用例期间的启动时间。
  • @Val 谢谢我会读的。

标签: elasticsearch


【解决方案1】:

没有办法将所有索引都存储到内存中。 index.store.type: memory 确实存在于 ES 1.x 中,但 disappeared in ES 2.0 很久以前。

您可以通过修改 te log4j2.properties 文件并将所有记录器设置为关闭来 disable all logging(并且可以选择使用 NullAppender)

logger.action.level = OFF
rootLogger.level = OFF
logger.deprecation.level = OFF
logger.index_search_slowlog_rolling.level = OFF
logger.index_indexing_slowlog.level = OFF
logger.xpack_security_audit_logfile.level = OFF

关于禁用发现,您可以通过设置 discovery.type=single-node 来解决问题

【讨论】:

    猜你喜欢
    • 2010-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-13
    • 1970-01-01
    • 1970-01-01
    • 2019-03-09
    • 1970-01-01
    相关资源
    最近更新 更多