Rest High level client performance


I'm doing some research how to utilize elasticsearch cluster in best way.
I have written simple java application that is using Rest High level client and setup of 2 elasticsearch nodes with 1 index that contains 2 shards and 0 replicas.

The problems that I encountered is that performance is not increasing with second node as I had around 7000 index request per second with 1 node and 1 shard the same performance I receive with 2 nodes and 2 shards with 0 replicas.

The code that it's quite simple:

Flux.range(1, 1000000000)
    .subscribe(next -> {
    }, error -> {
        logger.error("Received error: ", error);
    }, () -> {"Completed");

Method that is performing send operation

    private Mono<IndexResponse> index(IndexRequest indexRequest) {
        return Mono.create(monoSink -> {
            client.indexAsync(indexRequest, RequestOptions.DEFAULT, new ActionListener<IndexResponse>() {
                public void onResponse(IndexResponse indexResponse) {

                public void onFailure(Exception e) {
                    logger.error("Encounter problem during document indexing:", e);

Rest High level client is builded like this:

    public RestClientBuilder restClientBuilder() {
        HttpHost[] hosts =

        RestClientBuilder builder = RestClient.builder(hosts);
        builder.setHttpClientConfigCallback(b -> b.setDefaultHeaders(
                Collections.singleton(new BasicHeader(HttpHeaders.ACCEPT_ENCODING, "gzip"))))
                .setRequestConfigCallback(b -> b.setContentCompressionEnabled(true));

        builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
            public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
                return httpClientBuilder;
        return builder;

Client is configured to use those 2 nodes addresses.

What I'm missing ? Maybe someone could point me where I should look for the information ?

1 Like

First thing you should do is to use the BULK API:

Specifically in Java I'd recommend using the Bulk Processor:

1 Like

In my case it's impossible to use Bulk API, I have a case where it's needed to process message by message and index them.

Me previous numbers were incorrect as I was bound to CPU on local machine, when I tried the same on cloud machine with more CPU i received results that 1 node could handle around 16k index requests but after adding second node and second shard throughput only jumped to around 21.5k.

So i'm trying to figure out why I'm not able to receive lineare scalability ?

Why that? What is the difference an indexAsync operation?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.