# Long time to create TransportClient object

**URL:** <https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579>\
**Category:** Elasticsearch\
**Created:** [July 28, 2016, 6:21am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579 "2016-07-28T06:21:23Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinayakshukre](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vinayakshukre](https://discuss.elastic.co/u/vinayakshukre)\
**Post date:** [July 28, 2016, 6:21am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/1 "2016-07-28T06:21:23Z")

</div>

I am using below Java code to create Transportclient object.

```
               logger.info("Starting creation of Transport Client object");
		try {
			Settings settings = Settings.settingsBuilder().put("cluster.name", clusterName) .put("client.transport.sniff", sniff).build();
			
			client = TransportClient.builder().settings(settings).build();
			  
			logger.info("Transport client object created successfully");

                   }catch(){}

```

Time between two log statements is 12 to 13 seconds. Is there any reason why it takes so long to create this object? Do I have something wrong in my configuration ?

---

<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:** [July 28, 2016, 6:33am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/2 "2016-07-28T06:33:37Z")

</div>

I think your code is correct.  
What happens if you remove "sniff" option?

Are you connecting to a local node?

---

<div class="post-metadata">

**Author:** ![vinayakshukre](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vinayakshukre](https://discuss.elastic.co/u/vinayakshukre)\
**Post date:** [July 28, 2016, 7:17am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/3 "2016-07-28T07:17:55Z")

</div>

Without sniff option, it is same i.e. 12 seconds. I am connecting on Elasticsearch instance on my machine only. Debug logs are given below.

```
2016-07-28_12:42:32.653 [http-nio-8080-exec-4] INFO c.g.d.MyClass - Starting creation of Transport Client object without sniff option
2016-07-28_12:42:34.177 [http-nio-8080-exec-4] INFO org.elasticsearch.plugins - [Vermin] modules [], plugins [], sites []
2016-07-28_12:42:34.356 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [generic], type [cached], keep_alive [30s]
2016-07-28_12:42:34.381 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [index], type [fixed], size [8], queue_size [200]
2016-07-28_12:42:34.384 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [fetch_shard_store], type [scaling], min [1], size [16], keep_alive [5m]
2016-07-28_12:42:34.385 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [get], type [fixed], size [8], queue_size [1k]
2016-07-28_12:42:34.385 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [snapshot], type [scaling], min [1], size [4], keep_alive [5m]
2016-07-28_12:42:34.385 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [force_merge], type [fixed], size [1], queue_size [null]
2016-07-28_12:42:34.385 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [suggest], type [fixed], size [8], queue_size [1k]
2016-07-28_12:42:34.385 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [bulk], type [fixed], size [8], queue_size [50]
2016-07-28_12:42:34.385 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [warmer], type [scaling], min [1], size [4], keep_alive [5m]
2016-07-28_12:42:34.386 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [flush], type [scaling], min [1], size [4], keep_alive [5m]
2016-07-28_12:42:34.386 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [search], type [fixed], size [13], queue_size [1k]
2016-07-28_12:42:34.386 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [fetch_shard_started], type [scaling], min [1], size [16], keep_alive [5m]
2016-07-28_12:42:34.386 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [listener], type [fixed], size [4], queue_size [null]
2016-07-28_12:42:34.386 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [percolate], type [fixed], size [8], queue_size [1k]
2016-07-28_12:42:34.386 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [management], type [scaling], min [1], size [5], keep_alive [5m]
2016-07-28_12:42:34.386 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [refresh], type [scaling], min [1], size [4], keep_alive [5m]
2016-07-28_12:42:43.382 [http-nio-8080-exec-4] DEBUG org.elasticsearch.common.network - configuration:

lo
        inet 127.0.0.1 netmask:255.255.255.255 scope:host
        inet6 ::1 prefixlen:128 scope:host
        UP LOOPBACK mtu:65536 index:1

enp1s0
        inet 192.168.1.121 netmask:255.255.255.0 broadcast:192.168.1.255 scope:site
        inet6 fe80::428d:5cff:feee:e19c prefixlen:64 scope:link
        hardware 40:8D:5C:EE:E1:9C
        UP MULTICAST mtu:1500 index:2

2016-07-28_12:42:43.437 [http-nio-8080-exec-4] DEBUG org.elasticsearch.common.netty - using gathering [true]
2016-07-28_12:42:43.524 [http-nio-8080-exec-4] DEBUG org.elasticsearch.client.transport - [Vermin] node_sampler_interval[5s]
2016-07-28_12:42:44.793 [http-nio-8080-exec-4] DEBUG o.e.n.c.socket.nio.SelectorUtil - Using select timeout of 500
2016-07-28_12:42:44.793 [http-nio-8080-exec-4] DEBUG o.e.n.c.socket.nio.SelectorUtil - Epoll-bug workaround enabled = false
2016-07-28_12:42:44.917 [http-nio-8080-exec-4] INFO c.g.d.MyClass - Transport client object created successfully
```

---

<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:** [July 28, 2016, 7:45am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/4 "2016-07-28T07:45:21Z")

</div>

Apparently it takes 10s to get Network Information:

```auto
2016-07-28_12:42:34.386 [http-nio-8080-exec-4] DEBUG org.elasticsearch.threadpool - [Vermin] creating thread_pool [refresh], type [scaling], min [1], size [4], keep_alive [5m]
2016-07-28_12:42:43.382 [http-nio-8080-exec-4] DEBUG org.elasticsearch.common.network - configuration:

lo
        inet 127.0.0.1 netmask:255.255.255.255 scope:host
        inet6 ::1 prefixlen:128 scope:host
        UP LOOPBACK mtu:65536 index:1

enp1s0
        inet 192.168.1.121 netmask:255.255.255.0 broadcast:192.168.1.255 scope:site
        inet6 fe80::428d:5cff:feee:e19c prefixlen:64 scope:link
        hardware 40:8D:5C:EE:E1:9C
        UP MULTICAST mtu:1500 index:2

```

What is your elasticsearch version BTW?

---

<div class="post-metadata">

**Author:** ![vinayakshukre](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vinayakshukre](https://discuss.elastic.co/u/vinayakshukre)\
**Post date:** [July 28, 2016, 7:47am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/5 "2016-07-28T07:47:43Z")

</div>

To my wonder, when I call my API from my JUnit test case to search documents with sniff = true and sniff = false, it takes less than 1 second to create transport object. But when I call same API from my application deployed on same machine, it takes 12 seconds. ☹ ☹ What could be wrong in my application ?

---

<div class="post-metadata">

**Author:** ![vinayakshukre](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vinayakshukre](https://discuss.elastic.co/u/vinayakshukre)\
**Post date:** [July 28, 2016, 7:48am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/6 "2016-07-28T07:48:27Z")

</div>

I have ES 2.3.3

---

<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:** [July 28, 2016, 8:05am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/7 "2016-07-28T08:05:54Z")

</div>

Interesting.

When you run that with JUnit, are you connecting to the same external cluster or are you running a local cluster on your machine ?

---

<div class="post-metadata">

**Author:** ![vinayakshukre](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vinayakshukre](https://discuss.elastic.co/u/vinayakshukre)\
**Post date:** [July 28, 2016, 8:06am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/8 "2016-07-28T08:06:38Z")

</div>

Its same cluster in both cases  
☹

---

<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:** [July 28, 2016, 8:19am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/9 "2016-07-28T08:19:08Z")

</div>

Is your application and your JUnit tests running from the same machine as well?

---

<div class="post-metadata">

**Author:** ![vinayakshukre](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vinayakshukre](https://discuss.elastic.co/u/vinayakshukre)\
**Post date:** [July 28, 2016, 8:42am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/10 "2016-07-28T08:42:24Z")

</div>

yes. Everything is on same machine. ES cluster, Junit and my application.

---

<div class="post-metadata">

**Author:** ![vinayakshukre](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vinayakshukre](https://discuss.elastic.co/u/vinayakshukre)\
**Post date:** [July 28, 2016, 8:50am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/11 "2016-07-28T08:50:54Z")

</div>

One thing I noticed. Sometimes that object creation takes 4 seconds. I have set network.host property in elasticsearch.yml file to my hostname. ( I have observed that when I am not connected at all to LAN then my elasticsearch node does not start as it is not able to resolve my hostname.) So is that time varying because of network speed? I have a very bad LAN setup. Many times it goes down.

---

<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:** [July 28, 2016, 9:26am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/12 "2016-07-28T09:26:21Z")

</div>

Do you try using IP address or host name?  
If hostname, may be it's a DNS resolution thing?

---

<div class="post-metadata">

**Author:** ![vinayakshukre](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vinayakshukre](https://discuss.elastic.co/u/vinayakshukre)\
**Post date:** [July 28, 2016, 9:27am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/13 "2016-07-28T09:27:03Z")

</div>

ok... I will try with IP address and revert in some time.

---

<div class="post-metadata">

**Author:** ![vinayakshukre](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vinayakshukre](https://discuss.elastic.co/u/vinayakshukre)\
**Post date:** [July 29, 2016, 7:58am UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/14 "2016-07-29T07:58:48Z")

</div>

With IP addresses it is taking around 3 seconds. Does that mean my DNS query is taking very long to resolve ? By the way, thank you very much for spending time on my issue. I really appreciate your help.

---

<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 5, 2017, 10:31pm UTC](https://discuss.elastic.co/t/long-time-to-create-transportclient-object/56579/15 "2017-07-05T22:31:52Z")

</div>


