# Providing your own ThreadPool to node client

**URL:** <https://discuss.elastic.co/t/providing-your-own-threadpool-to-node-client/7657>\
**Category:** Elasticsearch\
**Created:** [May 11, 2012, 9:12am UTC](https://discuss.elastic.co/t/providing-your-own-threadpool-to-node-client/7657 "2012-05-11T09:12:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Clegg](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Andrew\_Clegg](https://discuss.elastic.co/u/Andrew_Clegg)\
**Post date:** [May 11, 2012, 9:12am UTC](https://discuss.elastic.co/t/providing-your-own-threadpool-to-node-client/7657/1 "2012-05-11T09:12:42Z")

</div>

What is the correct way to provide your own ThreadPool for the java  
Node client to use?

I notice that NodeClient can take a ThreadPool in the constructor, but  
the normal way to obtain a NodeClient is from node.client() so you  
don't get the option to provide one.

Alternatively, how can I change the settings of the thread pool to  
use?

My use case is that I am setting up HBase to push new data into  
ElasticSearch at quite high volumes, but I want to be able to control  
how many index calls happen in parallel.

Or does a single NodeClient push all requests through a single thread  
anyway, no matter how many threads it's shared between?

Thanks,

Andrew.

---

<div class="post-metadata">

**Author:** ![Andrew\_Clegg](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Andrew\_Clegg](https://discuss.elastic.co/u/Andrew_Clegg)\
**Post date:** [May 11, 2012, 9:19am UTC](https://discuss.elastic.co/t/providing-your-own-threadpool-to-node-client/7657/2 "2012-05-11T09:19:56Z")

</div>

Sorry -- I think this question is moot. On re-reading these docs:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

it seems the threading only applies when the Node you got the Client  
from actually _contains_ the index shard.

In our case this won't be true, we'll be using a client-only node  
sending to a remote shard.

I guess this means calls happen synchronously, so we'll need to handle  
background writes ourselves, right?

On May 11, 10:12 am, Andrew Clegg [andrew.cl...@gmail.com](mailto:andrew.cl...@gmail.com) wrote:

> What is the correct way to provide your own ThreadPool for the java  
> Node client to use?
> 
> I notice that NodeClient can take a ThreadPool in the constructor, but  
> the normal way to obtain a NodeClient is from node.client() so you  
> don't get the option to provide one.
> 
> Alternatively, how can I change the settings of the thread pool to  
> use?
> 
> My use case is that I am setting up HBase to push new data into  
> Elasticsearch at quite high volumes, but I want to be able to control  
> how many index calls happen in parallel.
> 
> Or does a single NodeClient push all requests through a single thread  
> anyway, no matter how many threads it's shared between?
> 
> Thanks,
> 
> Andrew.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 13, 2012, 12:16pm UTC](https://discuss.elastic.co/t/providing-your-own-threadpool-to-node-client/7657/3 "2012-05-13T12:16:37Z")

</div>

You can control if the call will be async or not based on the API (its  
always "async" in a sense, to you can control if you want to wait for it or  
not). You can still control the thread pools on the actual data nodes in  
the cluster ofcourse using the thread pool configuration:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/modules/threadpool.html).

On Fri, May 11, 2012 at 12:19 PM, Andrew Clegg [andrew.clegg@gmail.com](mailto:andrew.clegg@gmail.com)wrote:

> Sorry -- I think this question is moot. On re-reading these docs:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/java-api/index_.html)
> 
> it seems the threading only applies when the Node you got the Client  
> from actually _contains_ the index shard.
> 
> In our case this won't be true, we'll be using a client-only node  
> sending to a remote shard.
> 
> I guess this means calls happen synchronously, so we'll need to handle  
> background writes ourselves, right?
> 
> On May 11, 10:12 am, Andrew Clegg [andrew.cl...@gmail.com](mailto:andrew.cl...@gmail.com) wrote:
> 
> > What is the correct way to provide your own ThreadPool for the java  
> > Node client to use?
> > 
> > I notice that NodeClient can take a ThreadPool in the constructor, but  
> > the normal way to obtain a NodeClient is from node.client() so you  
> > don't get the option to provide one.
> > 
> > Alternatively, how can I change the settings of the thread pool to  
> > use?
> > 
> > My use case is that I am setting up HBase to push new data into  
> > Elasticsearch at quite high volumes, but I want to be able to control  
> > how many index calls happen in parallel.
> > 
> > Or does a single NodeClient push all requests through a single thread  
> > anyway, no matter how many threads it's shared between?
> > 
> > Thanks,
> > 
> > Andrew.

---

<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:29am UTC](https://discuss.elastic.co/t/providing-your-own-threadpool-to-node-client/7657/4 "2017-07-06T03:29:03Z")

</div>


