# EsRejectedExecutionException when just refresh kibana

**URL:** <https://discuss.elastic.co/t/esrejectedexecutionexception-when-just-refresh-kibana/116166>\
**Category:** Elasticsearch\
**Created:** [January 19, 2018, 6:03am UTC](https://discuss.elastic.co/t/esrejectedexecutionexception-when-just-refresh-kibana/116166 "2018-01-19T06:03:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zt\_Zeng](https://avatars.discourse-cdn.com/v4/letter/z/b77776/32.png) [@Zt\_Zeng](https://discuss.elastic.co/u/Zt_Zeng)\
**Post date:** [January 19, 2018, 6:03am UTC](https://discuss.elastic.co/t/esrejectedexecutionexception-when-just-refresh-kibana/116166/1 "2018-01-19T06:03:43Z")

</div>

Recently the Kibana fail to show any content. It just show empty or give us the error. Check the log of Elasticsearch, we found the very long `EsRejectedExecutionException` for search queue:

`rejected execution of org.elasticsearch.transport.TransportService$7@16130b66 on EsThreadPoolExecutor[search, queue capacity = 1000, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@6c9b1b8d[Running, pool size = 25, active threads = 25, queued tasks = 1832, completed tasks = 200517]]`

Following the suggestions from this [post](https://discuss.elastic.co/t/rejected-execution-queue-capacity-1000/89954), we have checked slow query, gc, io but found nothing.

```
    "gc" : {
      "collectors" : {
        "young" : {
          "collection_count" : 1662,
          "collection_time" : "53.1s",
          "collection_time_in_millis" : 53169
        },
        "old" : {
          "collection_count" : 1,
          "collection_time" : "229ms",
          "collection_time_in_millis" : 229
        }
      }
    },

```

And at the same time, to query node stats it give us:

```
    "search" : {
      "threads" : 25,
      "queue" : 0,
      "active" : 0,
      "rejected" : 37364,
      "largest" : 25,
      "completed" : 204375

```

It seems that this conflict with the log content: queued task is 0?

By the way, just a simple refresh of Kibana or change of filter will cause very long EsRejectedExecutionException.

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [January 19, 2018, 9:21am UTC](https://discuss.elastic.co/t/esrejectedexecutionexception-when-just-refresh-kibana/116166/2 "2018-01-19T09:21:55Z")

</div>

I've also had issues with Kibana slowing down and failing in a percolator cluster we're running and from what you show it seems to be the same reason; too many tasks for the thread\_pool.search.queue\_size (which is 1000 by default) causing Elasticsearch to reject new tasks. Your node stats show you've already had 37,364 tasks rejected and 204,375 completed since the last reboot - so on that node 18% or almost 1 out of every 5 tasks are being rejected. Many of those tasks are likely to be from Kibana which is why it struggles.

A growing queue of tasks could indicate that your cluster is slowing down for some reason (perhaps over-sharding causing a huge cluster state?) or that the search volume is too high for the given number of nodes. The solution in my company was to add two more nodes to the cluster, reducing the number of tasks per node to well below the threshold and reducing the number of rejections to virtually zero. Our Kibana instance has behaved well since then.

---

<div class="post-metadata">

**Author:** ![Zt\_Zeng](https://avatars.discourse-cdn.com/v4/letter/z/b77776/32.png) [@Zt\_Zeng](https://discuss.elastic.co/u/Zt_Zeng)\
**Post date:** [January 20, 2018, 1:35am UTC](https://discuss.elastic.co/t/esrejectedexecutionexception-when-just-refresh-kibana/116166/3 "2018-01-20T01:35:52Z")

</div>

Can you share the what a proper shard number for a 8G, 32 core server node?

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [January 20, 2018, 6:38am UTC](https://discuss.elastic.co/t/esrejectedexecutionexception-when-just-refresh-kibana/116166/4 "2018-01-20T06:38:45Z")

</div>

I'm afraid there is no simple answer to that question, it all depends on the size and form of the documents in your indices, but in general it's better with few primary shards per index rather than many, to reduce the cluster state size.

In our case we aim at shard sizes of 20-50 G so for an index of 10-30 G we go for 1 primary shard while for an index of 100 G we opt for 3 (or perhaps 4 if we expect the index to grow) primary shards. Of course, sometimes it's hard to tell ahead of time so if an index turns out larger than we expected we simply reindex it into a new index with more or fewer primary shards to get the proper shard size.

Good luck!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 20, 2018, 8:37am UTC](https://discuss.elastic.co/t/esrejectedexecutionexception-when-just-refresh-kibana/116166/5 "2018-01-20T08:37:23Z")

</div>

What does `_cat/nodes?v` show?

---

<div class="post-metadata">

**Author:** ![Zt\_Zeng](https://avatars.discourse-cdn.com/v4/letter/z/b77776/32.png) [@Zt\_Zeng](https://discuss.elastic.co/u/Zt_Zeng)\
**Post date:** [January 25, 2018, 9:05am UTC](https://discuss.elastic.co/t/esrejectedexecutionexception-when-just-refresh-kibana/116166/6 "2018-01-25T09:05:22Z")

</div>

Thanks for your time, I solved my problem. It is because the log file rolling too often which create too many indices and overwhelming the queue.

---

<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 22, 2018, 9:05am UTC](https://discuss.elastic.co/t/esrejectedexecutionexception-when-just-refresh-kibana/116166/7 "2018-02-22T09:05:24Z")

</div>

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