# Elasticsearch One Server And Cluster Insert performance Almost the same! Why?

**URL:** <https://discuss.elastic.co/t/elasticsearch-one-server-and-cluster-insert-performance-almost-the-same-why/75703>\
**Category:** Elasticsearch\
**Created:** [February 20, 2017, 9:59am UTC](https://discuss.elastic.co/t/elasticsearch-one-server-and-cluster-insert-performance-almost-the-same-why/75703 "2017-02-20T09:59:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![617726909](https://avatars.discourse-cdn.com/v4/letter/6/ee59a6/32.png) [@617726909](https://discuss.elastic.co/u/617726909)\
**Post date:** [February 20, 2017, 9:59am UTC](https://discuss.elastic.co/t/elasticsearch-one-server-and-cluster-insert-performance-almost-the-same-why/75703/1 "2017-02-20T09:59:57Z")

</div>

Recently tested single and cluster insert performance is almost the same, I don't really know why? Use java API TransportClient Bulk Insert.

version:  
ElasticSearch 5.1.1

One Index:

```
  "settings" : {
    "index" : {
        "number_of_shards" : 5, 
        "number_of_replicas" : 0,
		"refresh_interval" : "30s"
    }
}

```

threads: 16 Bulk Insert:1000 docs(logs)  
per log 44 field , per log for 1kb

single :  
OS: Centos 7 8 cpus memery: 32GB  
JVM Size Indexing Rate (/s)  
4GB 6000~8000  
8GB 6000~8000  
16GB 6000~8000

cluster:  
OS One: Centos 7 8 cpus memery: 32GB  
master: JVM 4GB  
date:JVM 16GB

OS Two: Centos 6.5 8 cpus memery: 32GB  
date:JVM 16GB

Indexing Rate (/s) 6000~8000

I don't really know why?Bulk Insert docs performance is almost the same?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 20, 2017, 9:44pm UTC](https://discuss.elastic.co/t/elasticsearch-one-server-and-cluster-insert-performance-almost-the-same-why/75703/2 "2017-02-20T21:44:46Z")

</div>

What does your client code look like?

---

<div class="post-metadata">

**Author:** ![617726909](https://avatars.discourse-cdn.com/v4/letter/6/ee59a6/32.png) [@617726909](https://discuss.elastic.co/u/617726909)\
**Post date:** [February 21, 2017, 5:02am UTC](https://discuss.elastic.co/t/elasticsearch-one-server-and-cluster-insert-performance-almost-the-same-why/75703/3 "2017-02-21T05:02:43Z")

</div>

Java API client code:

1: set clusterName、ipAndPorts  
2:invoke initTransportClient method init connect  
3:invoke bulkInsertDocument method,and set (index,type,json String list)

```
public class ElasticSearchBuilder {

private TransportClient client;
private String clusterName;
private String[] ipAndPorts;

public void setClusterName(String clusterName) {
    this.clusterName = clusterName;
}

public void setIpAndPorts(String[] ipAndPorts) {
    this.ipAndPorts = ipAndPorts;
}

public void initTransportClient() throws Exception {
    if (client != null) {
        client.close();
    }
    Settings settings = Settings.builder()
            .put("cluster.name", clusterName)
            .put("client.transport.sniff", true)
            .build();
    client = new PreBuiltTransportClient(settings);
    if (ipAndPorts == null || ipAndPorts.length < 1) {
        throw new NullPointerException("IP List is NULL");
    }
    for (String ipAndPort : ipAndPorts) {
        String[] ipAndPortString = ipAndPort.split(":");
        client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(ipAndPortString[0]), Integer.parseInt(ipAndPortString[1])));
    }
}

public boolean bulkInsertDocument(String index, String type, List<String> jsonList) throws Exception {
    BulkRequestBuilder bulkRequest = client.prepareBulk();
    if (jsonList != null && jsonList.size() > 0) {
        for (String jsonData : jsonList) {
            bulkRequest.add(client.prepareIndex(index, type).setSource(jsonData));
        }
    }
    BulkResponse bulkResponse = bulkRequest.get();
    return !bulkResponse.hasFailures();
}

public void closeTransportClient() {
    client.close();
}

```

}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 21, 2017, 5:03am UTC](https://discuss.elastic.co/t/elasticsearch-one-server-and-cluster-insert-performance-almost-the-same-why/75703/4 "2017-03-21T05:03:09Z")

</div>

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