# ES 6.x - Timeout by REST API operations

**URL:** <https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773>\
**Category:** Elasticsearch\
**Created:** [May 13, 2019, 9:29am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773 "2019-05-13T09:29:56Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![EldrosKandar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eldroskandar/32/33188_2.png) [@EldrosKandar](https://discuss.elastic.co/u/EldrosKandar)\
**Post date:** [May 13, 2019, 9:29am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/1 "2019-05-13T09:29:56Z")

</div>

This issue appears on ES 6.7

I've been trying to create an ILM policy to delete old indices. I used first the Kibana Console and got a 500 Internal Server Error back.

So I tried the following curl call on the server:

```
curl -X PUT "localhost:9200/_ilm/policy/delete_old_indices_policy" -H 'Content-Type: application/json' -d'
{
    "policy": {
        "phases": {
            "hot": {
                "actions": {
                    "set_priority": {
                        "priority": 100
                    }
                }
            },
            "delete": {
                "min_age": "30d",
                "actions": {
                    "delete": {}
                }
            }
        }
    }
}

```

I got the following error

> {"error":{"root\_cause":[{"type":"process\_cluster\_event\_timeout\_exception","reason":"failed to process cluster event (put-lifecycle-delete\_old\_indices\_policy) within 30s"}],"type":"process\_cluster\_event\_timeout\_exception","reason":"failed to process cluster event (put-lifecycle-delete\_old\_indices\_policy) within 30s"},"status":503}

What can I do to create the policy?

EDIT: This issue seems to appear for any kind of curl operation I try to make, not only creating policy.

---

<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:** [May 13, 2019, 9:25pm UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/2 "2019-05-13T21:25:48Z")

</div>

This part of the error:

> [@EldrosKandar](#):
>
> "failed to process cluster event (put-lifecycle-delete\_old\_indices\_policy) within 30s"

Indicates that within 30 seconds, the master node wasn't able to process the cluster state update when the policy was added. This usually means that your cluster is overloaded and unable to process the request.

---

<div class="post-metadata">

**Author:** ![EldrosKandar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eldroskandar/32/33188_2.png) [@EldrosKandar](https://discuss.elastic.co/u/EldrosKandar)\
**Post date:** [May 20, 2019, 7:56am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/3 "2019-05-20T07:56:46Z")

</div>

I increased the resources of the server, but I still get the error... I will have a look at activating Monitoring/Uptime to see if it helps get more information on why it fails.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 20, 2019, 8:41am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/4 "2019-05-20T08:41:52Z")

</div>

How many indices and shards do you have in the cluster? If you have a lot this can lead to a large cluster state and slow updates.

---

<div class="post-metadata">

**Author:** ![EldrosKandar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eldroskandar/32/33188_2.png) [@EldrosKandar](https://discuss.elastic.co/u/EldrosKandar)\
**Post date:** [May 20, 2019, 8:50am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/5 "2019-05-20T08:50:41Z")

</div>

I've got about 30 indices for the data I ingest each with 5 primary shards and 5 replica shards (now that I set my second node to be a data node too), also about 20 diverse monitoring and kibana indices each with 1 primary and 1 replica. (Which I hope won't get touched by ILM I hope now that I think about it.)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 20, 2019, 8:52am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/6 "2019-05-20T08:52:22Z")

</div>

How many indices and shards in total in the cluster? Have you read [this blog post](https://www.elastic.co/blog/how-many-shards-should-i-have-in-my-elasticsearch-cluster)?

---

<div class="post-metadata">

**Author:** ![EldrosKandar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eldroskandar/32/33188_2.png) [@EldrosKandar](https://discuss.elastic.co/u/EldrosKandar)\
**Post date:** [May 20, 2019, 9:09am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/7 "2019-05-20T09:09:03Z")

</div>

Using the Shards and Indices API, I count currently 54 indices and 380 shards (190 primary and 190 replicas). All shards are below 10GB (maximum is 8.8). Cluster countains 2 nodes (1 master/data/ingest, 1 data/ingest).

I just read the blog post, but I'll prolly need to re-read, as it is a lot of information to digest.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 20, 2019, 9:12am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/8 "2019-05-20T09:12:05Z")

</div>

If that is the total number of shards and indices and not what is created daily it does not sound excessive.

---

<div class="post-metadata">

**Author:** ![EldrosKandar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eldroskandar/32/33188_2.png) [@EldrosKandar](https://discuss.elastic.co/u/EldrosKandar)\
**Post date:** [May 20, 2019, 9:14am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/9 "2019-05-20T09:14:11Z")

</div>

Yes it is the total number at the moment, containing indices which were created in the last 30 days, as well as the .security, .kibana\*, .elastalert\_status, labels and ingest indices.

After reading the blog, I'm considering reducing the number of shards in the daily indices though, so they are a bit bigger. maybe using the Shrink API.

---

<div class="post-metadata">

**Author:** ![EldrosKandar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eldroskandar/32/33188_2.png) [@EldrosKandar](https://discuss.elastic.co/u/EldrosKandar)\
**Post date:** [June 4, 2019, 3:00pm UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/10 "2019-06-04T15:00:14Z")

</div>

Still having a issue, but I've been dealing on [another issue about bulk failure not being handled](https://discuss.elastic.co/t/tracking-down-which-pipelines-fails-to-parse/181763) and my hope is that it will help free some compute resources which would have been taken by the ingest/bulk operations.

---

<div class="post-metadata">

**Author:** ![EldrosKandar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eldroskandar/32/33188_2.png) [@EldrosKandar](https://discuss.elastic.co/u/EldrosKandar)\
**Post date:** [June 7, 2019, 8:13am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/11 "2019-06-07T08:13:14Z")

</div>

Well I can't do any changes to pipelines, as I get also timeout to policies, so I'm back to square one.

I've seen the Webinar from @davemoore on sizing and scaling and from my limited understanding, it seems that the bottleneck is with the Compute resource, which would mean if we simplify things I could throw more CPUs at the problem, but one could think that 8 CPUs in a 2 instance cluster would be enough... but I have the feeling I am oversimplifying the issue there.

@Christian_Dahlqvist any further idea I could follow or things I should investigate to have a clearer picture of the issue?

---

<div class="post-metadata">

**Author:** ![EldrosKandar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eldroskandar/32/33188_2.png) [@EldrosKandar](https://discuss.elastic.co/u/EldrosKandar)\
**Post date:** [June 7, 2019, 9:00am UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/12 "2019-06-07T09:00:40Z")

</div>

So I can attack the problem from different angle:

- Give more resources to the nodes:

This is something I already done relatively recently, as I had performance issue concerning querying and ingesting the logs, I increased CPU and RAM resources on both nodes. Now both nodes have 8 CPU and main and second node have respectively 64 and 14GB RAM. Also I increased Heap Size for the elasticsearch deamon to the maximum of 31GB. Storage is far from an issue, as I have more than half the space available on the volumes I mounted to store the elasticsearch data, but then maybe I have to consider the networking aspect because of it's configuration.

- Add node/redistribute the roles:

I have two nodes a big one and a little one. Both have all the roles, although the little one didn't use to have the data role, but it helped me with the previously mentioned. So now, maybe I need to add a node with a dedicated role, or remove one of the role on the existing node?

- Update to 7.x

I am currently on 6.7.2, recently updated from 6.3, but maybe I should consider updating?

- More monitoring/benchmarking

I could try to set up such tool as Rally, Uptime or Monitoring to get more data and identify the bottleneck.

---

<div class="post-metadata">

**Author:** ![EldrosKandar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eldroskandar/32/33188_2.png) [@EldrosKandar](https://discuss.elastic.co/u/EldrosKandar)\
**Post date:** [June 26, 2019, 12:46pm UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/13 "2019-06-26T12:46:36Z")

</div>

@Christian_Dahlqvist I've just read about the `_nodes/hot_threads` API and thought it would be useful to find out where the resources are used as it could be useful to determine the bottleneck, however, I have difficulties interpreting the results, here is the summary of the threads for the main node:

```
74.5% (372.4ms out of 500ms) cpu usage by thread 'elasticsearch[es1][masterService#updateTask][T#1]'
21.7% (108.3ms out of 500ms) cpu usage by thread 'elasticsearch[es1][write][T#3]'
17.4% (87.1ms out of 500ms) cpu usage by thread 'elasticsearch[es1][write][T#4]'
15.5% (77.5ms out of 500ms) cpu usage by thread 'elasticsearch[es1][http_server_worker][T#6]'
15.5% (77.4ms out of 500ms) cpu usage by thread 'elasticsearch[es1][write][T#2]'
13.4% (67.2ms out of 500ms) cpu usage by thread 'elasticsearch[es1][write][T#5]'
10.0% (50ms out of 500ms) cpu usage by thread 'elasticsearch[es1][write][T#6]'
7.8% (38.8ms out of 500ms) cpu usage by thread 'elasticsearch[es1][write][T#1]'
5.7% (28.7ms out of 500ms) cpu usage by thread 'elasticsearch[es1][refresh][T#2]'
5.6% (28.2ms out of 500ms) cpu usage by thread 'elasticsearch[es1][write][T#8]'
4.8% (23.8ms out of 500ms) cpu usage by thread 'elasticsearch[es1][write][T#7]'
4.4% (21.9ms out of 500ms) cpu usage by thread 'elasticsearch[es1][http_server_worker][T#10]'
1.1% (5.2ms out of 500ms) cpu usage by thread 'elasticsearch[es1][management][T#2]'
0.0% (117.5micros out of 500ms) cpu usage by thread 'ticker-schedule-trigger-engine'
0.0% (0s out of 500ms) cpu usage by thread 'ml-cpp-log-tail-thread'
0.0% (0s out of 500ms) cpu usage by thread 'elasticsearch[keepAlive/6.7.2]'
0.0% (0s out of 500ms) cpu usage by thread 'DestroyJavaVM'
0.0% (0s out of 500ms) cpu usage by thread 'process reaper'
0.0% (0s out of 500ms) cpu usage by thread 'Connection evictor'

```

So it seems a lot of write threads. After I try to update a pipeline (with timeout), a new thread appears named `'elasticsearch[es1][clusterApplierService#updateTask][T#1]'`. After trying to add an ILM policy the `'elasticsearch[es1][http_server_worker][T#6]'`thread takes most of the time.

I've saved the all stack trace in case details for specific threads are needed.

Anyway, as I suspect the bulk and ingest operation to hog the resources (without any concrete proof, relying only on my observation that data seems to be imported in Elasticsearch just fine), I plan to make a scheduled maintenance and [disabled data and ingest role on the cluster](https://discuss.elastic.co/t/stopping-any-incoming-data/187497) for a finite time while I'm trying to do a few operations which I hope will help (especially when it comes to [absent failiure handling](https://discuss.elastic.co/t/tracking-down-which-pipelines-fails-to-parse/)).

---

<div class="post-metadata">

**Author:** ![EldrosKandar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eldroskandar/32/33188_2.png) [@EldrosKandar](https://discuss.elastic.co/u/EldrosKandar)\
**Post date:** [June 27, 2019, 12:24pm UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/14 "2019-06-27T12:24:18Z")

</div>

Even after I tried to disable the roles, I couldn't execute any REST API call without going to timeout. Slowly it is becoming quite critical that I'm able to do some changes, but I don't know what to do.

Can anybody help me?

---

<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 25, 2019, 12:24pm UTC](https://discuss.elastic.co/t/es-6-x-timeout-by-rest-api-operations/180773/15 "2019-07-25T12:24:23Z")

</div>

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