【发布时间】: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);
我可以更改哪些设置来缩短启动时间?
- 我不需要在测试运行中保留索引,因此可以将索引保存在内存中。我没有看到
memory在 6.4 store types 中列出 - 是否存在导致整个集群在不写入磁盘的情况下运行的设置(禁用日志记录、禁用文件存储、禁用 pid/状态)?
- 集群将是单节点的,因此我可以禁用发现,但我没有找到该设置。编辑:
discovery.type=single-node6.4
【问题讨论】:
-
我为各种版本找到了一些很好的答案here。
discovery.type=single-node剃掉 4 秒。 -
我怀疑这在很大程度上是由于庞大的代码库/功能集和 JVM 速度缓慢,并且仅使用 Hotspot 运行,而不是例如格拉尔。这真的很不幸。 PostgreSQL 需要 1 秒才能开始测试。 Elasticsearch 需要 8 秒。
-
@PaulDraper 你在运行什么版本?这里还有一个interesting investigation 测试用例期间的启动时间。
-
@Val 谢谢我会读的。
标签: elasticsearch