# Unbalanced primary shards affects search queries?

**URL:** <https://discuss.elastic.co/t/unbalanced-primary-shards-affects-search-queries/215293>\
**Category:** Elasticsearch\
**Created:** [January 16, 2020, 10:40am UTC](https://discuss.elastic.co/t/unbalanced-primary-shards-affects-search-queries/215293 "2020-01-16T10:40:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ragian](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@ragian](https://discuss.elastic.co/u/ragian)\
**Post date:** [January 16, 2020, 10:40am UTC](https://discuss.elastic.co/t/unbalanced-primary-shards-affects-search-queries/215293/1 "2020-01-16T10:40:05Z")

</div>

In a lot of topic is said that we shouldn't worry about balancing primary shards across all nodes.

Currently my primaries are highly unbalanced in my elasticsearch cluster (3 nodes with elastic 6.4.0).

 ![cerebro](https://us1.discourse-cdn.com/elastic/original/3X/a/0/a0f80de49bf64acb9135ca87d6944fe203f9b860.jpeg)

On the cluster are performed mainly read/search queries and according to the documentation they  
should balanced between the node of the shard, but it seems that they are performed only  
on the server 3 (that one with high load).

```
curl -XGET 's01.node.consul:9200/_cat/thread_pool' | grep "search"
  % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 1845 100 1845 0 0 75275 0 --:--:-- --:--:-- --:--:-- 76875
"s01" search 0 0 2
"s02" search 0 0 0
"s03" search 7 8 164

```

This is one of the example of the queries:

```
GET host.elastic:9200/index_*/_search/?scroll=120s 
{
	"query": {
		"bool": {
			"must": [{
				"match": {
					"param1": "1111"
				}
			}, {
				"match": {
					"param2": "XXXXXX"
				}
			}]
		}
	},
	"sort": [{
		"entered_date": {
			"order": "asc"
		}
	}],
	"size": 1000
}
```

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [January 16, 2020, 10:54am UTC](https://discuss.elastic.co/t/unbalanced-primary-shards-affects-search-queries/215293/2 "2020-01-16T10:54:34Z")

</div>

Searches behave no differently between primaries and replicas, so there's something else going on here.

The simplest way to find out which nodes are performing a search is probably to use the [profile API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-profile.html). In the response each shard involved in the search is identified by a string of the form `[2aE02wS1R8q_QFnYu6vDVQ][twitter][0]` where the first part is the node ID. I expect if you run your search with the profiler then you will see it using a mix of nodes.

---

<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:** [February 13, 2020, 10:54am UTC](https://discuss.elastic.co/t/unbalanced-primary-shards-affects-search-queries/215293/3 "2020-02-13T10:54:38Z")

</div>

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