# Limit no. of thread for msearch

**URL:** https://discuss.elastic.co/t/limit-no-of-thread-for-msearch/80745
**Category:** Elasticsearch
**Created:** [March 30, 2017, 8:51pm UTC](https://discuss.elastic.co/t/limit-no-of-thread-for-msearch/80745 "2017-03-30T20:51:10Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![venkata\_sreekanth\_bh](https://avatars.discourse-cdn.com/v4/letter/v/65b543/32.png) [@venkata\_sreekanth\_bh](https://discuss.elastic.co/u/venkata_sreekanth_bh)
#### Post date: [March 30, 2017, 8:51pm UTC](https://discuss.elastic.co/t/limit-no-of-thread-for-msearch/80745/1 "2017-03-30T20:51:10Z")

</div>

I would like to limit the no of threads allocated to msearch. In my use case, I have users submitting hundreds of query strings, and other users submit single query strings. when these bulk searches show up, they take up all of the threads and cpu usage. I would like leave at least 2 threads on each node to service single queries. How do solve this issue?

---

<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: [March 31, 2017, 12:48am UTC](https://discuss.elastic.co/t/limit-no-of-thread-for-msearch/80745/2 "2017-03-31T00:48:23Z")

</div>

You did not say the version.

In 2.x, there is nothing that you can do (other than limit the number of searches in a single msearch request), it is indeed a problem.

In 5.x there is the `max_concurrent_searches` parameter that you can use to limit the number of concurrent requests from a single msearch batch. This parameter has a reasonable default based on the default size of the search thread pool.

---

<div class="post-metadata">

### Author: ![venkata\_sreekanth\_bh](https://avatars.discourse-cdn.com/v4/letter/v/65b543/32.png) [@venkata\_sreekanth\_bh](https://discuss.elastic.co/u/venkata_sreekanth_bh)
#### Post date: [March 31, 2017, 9:41pm UTC](https://discuss.elastic.co/t/limit-no-of-thread-for-msearch/80745/3 "2017-03-31T21:41:25Z")

</div>

I am running 5.1.2

I want to limit the thread pool that is assigned to bulk, or to make the question more clear how do I ensure the regular searches don't get effected by bulk searches.

---

<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: [April 1, 2017, 11:32am UTC](https://discuss.elastic.co/t/limit-no-of-thread-for-msearch/80745/4 "2017-04-01T11:32:07Z")

</div>

You can not, they share the same thread pool. The best that you can do is limit the number of concurrent searches from a single msearch request. This does not limit the thread pool from being consumed if multiple msearch requests are submitted. If you need the fine-grained management that you're describing, you need to put a traffic cop in front of Elasticsearch.

---

<div class="post-metadata">

### Author: ![venkata\_sreekanth\_bh](https://avatars.discourse-cdn.com/v4/letter/v/65b543/32.png) [@venkata\_sreekanth\_bh](https://discuss.elastic.co/u/venkata_sreekanth_bh)
#### Post date: [April 3, 2017, 3:04pm UTC](https://discuss.elastic.co/t/limit-no-of-thread-for-msearch/80745/5 "2017-04-03T15:04:22Z")

</div>

I notice that you are an engineer at elastic. In the future is it a possibility that you implement the option of a queue and set aside thread for multi search or at least prioritize single requests over bulk ones. The third option of having a separate cluster for bulk and single is not very appealing.

---

<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: [April 4, 2017, 1:37am UTC](https://discuss.elastic.co/t/limit-no-of-thread-for-msearch/80745/6 "2017-04-04T01:37:38Z")

</div>

> [@venkata\_sreekanth\_bh](#):
>
> In the future is it a possibility that you implement the option of a queue and set aside thread for multi search or at least prioritize single requests over bulk ones.

I'm reluctant to add yet another thread pool to Elasticsearch, I think that we create too many threads as it is.

Also, prioritizing single requests over bulk thread pools is not something that we are likely to do, single requests are now treated as bulk requests with a single item in the payload anyway.

There have been requests to add the ability to attach a priority to requests, but we've resisted this.

> [@venkata\_sreekanth\_bh](#):
>
> The third option of having a separate cluster for bulk and single is not very appealing.

I do not see why you need a separate cluster, I merely meant fronting requests.

---

<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: [May 2, 2017, 1:37am UTC](https://discuss.elastic.co/t/limit-no-of-thread-for-msearch/80745/7 "2017-05-02T01:37:40Z")

</div>

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