12

I'm writing tests that start a elasticsearch 6.4 single-node cluster to ensure that my queries behave as expected. It takes about 10 seconds for the cluster to start an my tests RestHighLevelClient to ping it without a connection error

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);

Are there settings I can change to improve startup time?

  • I don't need to persist indexes across test runs, so the index could be kept in memory. I don't see memory listed in the 6.4 store types
  • Are there settings that cause the whole cluster to run without writing to disk (disable logging, disable file storage, disable pid/state)?
  • The cluster will be single-node so I can disable discovery, but I haven't found that setting. Edit: discovery.type=single-node in 6.4
everett1992
  • 2,351
  • 3
  • 27
  • 38
  • 1
    I found some good answers for various versions [here](https://stackoverflow.com/questions/16432300/how-to-config-single-node-for-single-cluster-standalone-cluster-elasticsearch). `discovery.type=single-node` shaves off 4 seconds. – everett1992 Sep 16 '19 at 21:43
  • I suspect a lot of this is due to a sprawling code base/feature set and JVM slowness and operating only with Hotspot, not e.g. Graal. It is really unfortunate. PostgreSQL takes 1s to start for tests. Elasticsearch takes 8s. – Paul Draper Feb 05 '22 at 17:27
  • 1
    @PaulDraper what version are you running? Also here is an [interesting investigation](https://github.com/elastic/elasticsearch/issues/28650) of startup times during test cases. – Val Feb 08 '22 at 07:55
  • @Val thanks I will read that. – Paul Draper Feb 09 '22 at 19:47

1 Answers1

7

There's no way so store all indexes into memory. index.store.type: memory did exist in ES 1.x but disappeared in ES 2.0 a long time ago.

You can disable all logging by modifying te log4j2.properties file and setting all loggers to OFF (and optionally use a 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

Regarding disabling the discovery, you got it right by setting discovery.type=single-node

Val
  • 207,596
  • 13
  • 358
  • 360