Questions on threads in elasticsearch


(sar) #1

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"
{
"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'

...
"threads" : {
"count" : 40,
"peak_count" : 51
...


(Jason Tedor) #2

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.


(sar) #3

Thanks @jasontedor
I used jstack and found out the details. Thanks for your help.


(system) #4