# What nodes should we give while connecting to ES cluster from java client

**URL:** <https://discuss.elastic.co/t/what-nodes-should-we-give-while-connecting-to-es-cluster-from-java-client/233826>\
**Category:** Elasticsearch\
**Created:** [May 22, 2020, 12:02am UTC](https://discuss.elastic.co/t/what-nodes-should-we-give-while-connecting-to-es-cluster-from-java-client/233826 "2020-05-22T00:02:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pinakinab](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@pinakinab](https://discuss.elastic.co/u/pinakinab)\
**Post date:** [May 22, 2020, 12:02am UTC](https://discuss.elastic.co/t/what-nodes-should-we-give-while-connecting-to-es-cluster-from-java-client/233826/1 "2020-05-22T00:02:38Z")

</div>

We are using elasticsearch with following topology:  
Dedicated master nodes: 3  
Dedicated data nodes: 6  
ES JAVA clients: 6

While connecting to ES cluster from a java client program, we provide comma separated data hostnames while creating REST

Here is a code snippet:

```auto
            private static synchronized RestHighLevelClient createConnection() {
            if(client == null) {
                client = new RestHighLevelClient(
                        RestClient.builder(
                                new HttpHost(HOST1, PORT, SCHEME),
                                new HttpHost(HOST2, PORT, SCHEME),
                                new HttpHost(HOST3, PORT, SCHEME)));
            }
            return client;
        }

```

1. Is this the right way of connecting to ES cluster?
2. Can we give comma separated master nodes instead of data nodes?
3. Will there be any performance hit if we use master nodes?

---

<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:** [June 19, 2020, 12:02am UTC](https://discuss.elastic.co/t/what-nodes-should-we-give-while-connecting-to-es-cluster-from-java-client/233826/2 "2020-06-19T00:02:42Z")

</div>

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