# Recommended way of connecting to the cluster

**URL:** <https://discuss.elastic.co/t/recommended-way-of-connecting-to-the-cluster/9884>\
**Category:** Elasticsearch\
**Created:** [November 29, 2012, 12:06pm UTC](https://discuss.elastic.co/t/recommended-way-of-connecting-to-the-cluster/9884 "2012-11-29T12:06:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henrik\_Nordvik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henrik_nordvik/32/1096_2.png) [@Henrik\_Nordvik](https://discuss.elastic.co/u/Henrik_Nordvik)\
**Post date:** [November 29, 2012, 12:06pm UTC](https://discuss.elastic.co/t/recommended-way-of-connecting-to-the-cluster/9884/1 "2012-11-29T12:06:03Z")

</div>

The reference says that there are two ways of connecting to elasticsearch  
as a client (considering Java here).

1. Create client node (nodeBuilde with client=true)
2. Create TransportClient with seed addresses.

What are the differences between these methods? When should I use one or  
the other? Pros/cons.  
The reference claims that option 1 is the most common, but is that really  
true?  
When I connect with the nodebuilder in client mode the client pops up in  
the cluster view in elasticsearch-head. Is there an overhead if I have lots  
of clients?

--

---

<div class="post-metadata">

**Author:** ![Henrik\_Nordvik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henrik_nordvik/32/1096_2.png) [@Henrik\_Nordvik](https://discuss.elastic.co/u/Henrik_Nordvik)\
**Post date:** [November 29, 2012, 2:59pm UTC](https://discuss.elastic.co/t/recommended-way-of-connecting-to-the-cluster/9884/2 "2012-11-29T14:59:17Z")

</div>

I found another topic that discussed the issue:  
[https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/guice/elasticsearch/TihFMAJjTR4/k5Wquq6JkS0J](https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/guice/elasticsearch/TihFMAJjTR4/k5Wquq6JkS0J)

But I couldn't find any conclusions.

On Thursday, November 29, 2012 1:06:03 PM UTC+1, Henrik Nordvik wrote:

> The reference says that there are two ways of connecting to elasticsearch  
> as a client (considering Java here).
> 
> 1. Create client node (nodeBuilde with client=true)
> 2. Create TransportClient with seed addresses.
> 
> What are the differences between these methods? When should I use one or  
> the other? Pros/cons.  
> The reference claims that option 1 is the most common, but is that really  
> true?  
> When I connect with the nodebuilder in client mode the client pops up in  
> the cluster view in elasticsearch-head. Is there an overhead if I have lots  
> of clients?

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 29, 2012, 3:14pm UTC](https://discuss.elastic.co/t/recommended-way-of-connecting-to-the-cluster/9884/3 "2012-11-29T15:14:03Z")

</div>

IMHO, using TransportClient has less overhead as the cluster doesn't have to  
detect when the node quit or join the cluster.  
NodeClient is using a little more threads.

That said, NodeClient automaticaly manage everything for you. With the transport  
client, you have to define some adresses (so autodiscovering is not available).

From my past project, I started with a NodeClient and finally used after some  
months the TransportClient. The only main reason is that I didn't want to see  
stack traces in elasticsearch logs when my JVM client is killed (as the node is  
removed hardly).

I'm not sure that you can really see any overhead when using NodeClient as this  
overhead is IMHO very tiny.

My 2 cents

Le 29 novembre 2012 à 15:59, Henrik Nordvik [henrikno@gmail.com](mailto:henrikno@gmail.com) a écrit :

> I found another topic that discussed the issue:
> 
> [Redirecting to Google Groups](https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/guice/elasticsearch/TihFMAJjTR4/k5Wquq6JkS0J)
> 
> But I couldn't find any conclusions.
> 
> On Thursday, November 29, 2012 1:06:03 PM UTC+1, Henrik Nordvik wrote:
> 
> > > The reference says that there are two ways of connecting to  
> > > elasticsearch as a client (considering Java here).
> > 
> > 1. Create client node (nodeBuilde with client=true)
> > 2. Create TransportClient with seed addresses.
> > 
> > What are the differences between these methods? When should I use one or  
> > the other? Pros/cons.  
> > The reference claims that option 1 is the most common, but is that really  
> > true?  
> > When I connect with the nodebuilder in client mode the client pops up in  
> > the cluster view in elasticsearch-head. Is there an overhead if I have lots  
> > of clients?
> > 
> > >
> 
> --

--  
David Pilato  
[http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<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:** [July 6, 2017, 3:02am UTC](https://discuss.elastic.co/t/recommended-way-of-connecting-to-the-cluster/9884/4 "2017-07-06T03:02:09Z")

</div>


