# Limit number of thread in ThreadPool while creating TransportClient in elasticsearch

**URL:** <https://discuss.elastic.co/t/limit-number-of-thread-in-threadpool-while-creating-transportclient-in-elasticsearch/21624>\
**Category:** Elasticsearch\
**Created:** [January 14, 2015, 4:58am UTC](https://discuss.elastic.co/t/limit-number-of-thread-in-threadpool-while-creating-transportclient-in-elasticsearch/21624 "2015-01-14T04:58:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [January 14, 2015, 4:58am UTC](https://discuss.elastic.co/t/limit-number-of-thread-in-threadpool-while-creating-transportclient-in-elasticsearch/21624/1 "2015-01-14T04:58:32Z")

</div>

I'm creating a TransportClient instance in elasticsearch. Below is the code  
for the same. The issue is I'm trying to lower the number of threads  
spawned with the threadpool that TransportClient initiates.

public static TransportClient getTransportClient(String ip, int port) {

```
ImmutableSettings.Builder settings = ImmutableSettings
        .settingsBuilder();
settings.put("cluster.name", "elasticsearch");
settings.put("threadpool.bulk.type", "fixed");
settings.put("threadpool.bulk.size" ,5);
settings.put("threadpool.bulk.queue_size", 5);
settings.put("threadpool.index.type" , "fixed");
settings.put("threadpool.index.size" , 5);
settings.put("threadpool.index.queue_size" , 10);
settings.put("threadpool.search.type", "fixed");
settings.put("threadpool.search.size" ,5);
settings.put("threadpool.search.queue_size", 5);
settings.build();

TransportClient instance = new TransportClient(settings)
        .addTransportAddress(new InetSocketTransportAddress(ip, port));

return instance;

```

}

But what ever settings I use my elasticsearch always initialing the  
threadpool with 12 threads. Guess that is the 4 time of CPU while  
calculating the threadpool size.

Please let me know what is the configuration to get the desirable threads.

Thanks,  
Bagui

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fbd03973-3706-4b59-a524-31a94d305c42%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fbd03973-3706-4b59-a524-31a94d305c42%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:39am UTC](https://discuss.elastic.co/t/limit-number-of-thread-in-threadpool-while-creating-transportclient-in-elasticsearch/21624/2 "2017-07-06T00:39:08Z")

</div>


