# Questions on threads in elasticsearch

**URL:** <https://discuss.elastic.co/t/questions-on-threads-in-elasticsearch/42955>\
**Category:** Elasticsearch\
**Created:** [February 28, 2016, 3:42pm UTC](https://discuss.elastic.co/t/questions-on-threads-in-elasticsearch/42955 "2016-02-28T15:42:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sar](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@sar](https://discuss.elastic.co/u/sar)\
**Post date:** [February 28, 2016, 3:42pm UTC](https://discuss.elastic.co/t/questions-on-threads-in-elasticsearch/42955/1 "2016-02-28T15:42:34Z")

</div>

Hi,

I'm trying to understand the threads spawned when the elasticsearch is started.  
So I downloaded elasticsearch-2.2.0.tar.gz, extracted and started elasticsearch with the default settings (without changing any configurations ) and found out that over 50 threads are spawned.

ps H | grep elastic | wc -l  
54

However I don't see those threads in the thread pool. But jvm stats show me that there are 40 threads.  
How can this explained? Are these threads spawned by java itself for JRE?

Thanks.

curl -XGET "[http://localhost:9200/\_nodes/stats/thread\_pool?pretty](http://localhost:9200/_nodes/stats/thread_pool?pretty)"  
{  
"cluster\_name" : "elasticsearch",  
"nodes" : {  
"2ociHL10QoKidA0HPCU2kQ" : {  
"timestamp" : 1456673730226,  
"name" : "Hisako Ichiki",  
"transport\_address" : "127.0.0.1:9300",  
"host" : "127.0.0.1",  
"ip" : ["127.0.0.1:9300", "NONE"],  
"thread\_pool" : {  
"bulk" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"fetch\_shard\_started" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"fetch\_shard\_store" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"flush" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"force\_merge" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"generic" : {  
"threads" : 1,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 4,  
"completed" : 39  
},  
"get" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"index" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"listener" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"management" : {  
"threads" : 2,  
"queue" : 0,  
"active" : 1,  
"rejected" : 0,  
"largest" : 2,  
"completed" : 7  
},  
"percolate" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"refresh" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"search" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"snapshot" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"suggest" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
},  
"warmer" : {  
"threads" : 0,  
"queue" : 0,  
"active" : 0,  
"rejected" : 0,  
"largest" : 0,  
"completed" : 0  
}  
}  
}  
}  
}

curl -XGET '[http://localhost:9200/\_nodes/stats/jvm?pretty](http://localhost:9200/_nodes/stats/jvm?pretty)'

...  
"threads" : {  
"count" : 40,  
"peak\_count" : 51  
...

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [February 28, 2016, 9:22pm UTC](https://discuss.elastic.co/t/questions-on-threads-in-elasticsearch/42955/2 "2016-02-28T21:22:11Z")

</div>

> [@sar](#):
>
> How can this explained? Are these threads spawned by java itself for JRE?

There are network threads and JVM threads that do not show up in the thread pool stats. Instead of using `ps` you can use `jstack` (which is provided with the JDK) and it will show the name of each thread; here you can clearly see the purpose of each thread.

---

<div class="post-metadata">

**Author:** ![sar](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@sar](https://discuss.elastic.co/u/sar)\
**Post date:** [February 29, 2016, 3:04pm UTC](https://discuss.elastic.co/t/questions-on-threads-in-elasticsearch/42955/3 "2016-02-29T15:04:13Z")

</div>

Thanks @jasontedor  
I used jstack and found out the details. Thanks for 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, 11:12pm UTC](https://discuss.elastic.co/t/questions-on-threads-in-elasticsearch/42955/4 "2017-07-05T23:12:50Z")

</div>


