Rolintocour
Rolintocour

Reputation: 3168

Elasticsearch client: speed up client creation

I am developing integration tests with elasticsearch. At the beginning I instantiate the client like this:

Settings settings = Settings.EMPTY;
Client client = new PreBuiltTransportClient(settings)
                .addTransportAddress(new TransportAddress(InetAddress.getByName("localhost", "9300"));

The elasticsearch server is embedded into a docker container, with following environment variables:

- cluster.name=elasticsearch
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.enabled=false
- xpack.monitoring.enabled=false
- xpack.graph.enabled=false
- xpack.watcher.enabled=false

At each test run, it takes up to 20s just for client creation.

Is there anyway to speed it up? Thx.

Upvotes: 0

Views: 81

Answers (1)

yora
yora

Reputation: 19

By default, Elasticsearch uses two ports to listen to external TCP traffic;

Port 9200 is used for all API calls over HTTP. This includes search and aggregations, monitoring, and anything else that uses a HTTP request. All client libraries will use this port to talk to Elasticsearch Port 9300 is a custom binary protocol used for communications between nodes in a cluster. For things like cluster updates, master elections, nodes joining/leaving, shard allocation

Upvotes: 0

Related Questions