# Search Requests - How threads work

**URL:** <https://discuss.elastic.co/t/search-requests-how-threads-work/88693>\
**Category:** Elasticsearch\
**Created:** [June 8, 2017, 9:45am UTC](https://discuss.elastic.co/t/search-requests-how-threads-work/88693 "2017-06-08T09:45:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chindhu\_hari](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@chindhu\_hari](https://discuss.elastic.co/u/chindhu_hari)\
**Post date:** [June 8, 2017, 9:45am UTC](https://discuss.elastic.co/t/search-requests-how-threads-work/88693/1 "2017-06-08T09:45:57Z")

</div>

@jpountz @jprante

I hit the following exception in my ES. It's a 2.3.2 with single node, 32 CPU linux machine. 5 shards per index. I'm querying on a particular index.  
I have few queries based upon the log entry below:

1. queued tasks = 1000 \<-- Does this number refer to only the incoming search requests or the total number of internal tasks that might have got initiated during a single search query (like fetch shard et al).

2. active threads = 49 \<-- Does this mean, for each search request a thread is assigned or is it for each shard? Say, my index has 5 shards and a search request is made against this index, does this mean 5 threads will allocated for this request or just 1?

Also, below, how does the fetch\_total and query\_total get calculated? For every search request of mine, I was expecting them to increase by 5(since it'll be hitting 5 shards), query\_total was increasing by 5, but fetch\_total gets increased by 1.

`{search: {open_contexts: 0, **query_total: 314575** ,query_time_in_millis: 6562305,query_current: 0, **fetch_total: 42058** ,fetch_time_in_millis: 161747,fetch_current: 0,scroll_total: 0,scroll_time_in_millis: 0,scroll_current: 0}`

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [June 8, 2017, 9:36pm UTC](https://discuss.elastic.co/t/search-requests-how-threads-work/88693/2 "2017-06-08T21:36:24Z")

</div>

> [@chindhu\_hari](#):
>
> 1. queued tasks = 1000 \<-- Does this number refer to only the incoming search requests or the total number of internal tasks that might have got initiated during a single search query (like fetch shard et al).

So this is any task that is on the "search" threadpool. For example, in a single node case querying an index with 5 primary shards, you will end up with 6 total tasks (1 coordinating task and 1 task for executing the query on each shard).

> [@chindhu\_hari](#):
>
> 1. active threads = 49 \<-- Does this mean, for each search request a thread is assigned or is it for each shard? Say, my index has 5 shards and a search request is made against this index, does this mean 5 threads will allocated for this request or just 1?

The `active_threads` are the number of threads currently processing a task in this particular threadpool. It is a per-node threadpool. If you have 5 shards on the node and a query is sent against all of them, that means 5 threads can work on executing the query (see the explanation above)

Hope this helps 🙂

---

<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, 9:36pm UTC](https://discuss.elastic.co/t/search-requests-how-threads-work/88693/3 "2017-07-06T21:36:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
