# Elasticsearch socket block OR timeout

**URL:** <https://discuss.elastic.co/t/elasticsearch-socket-block-or-timeout/202545>\
**Category:** Elasticsearch\
**Created:** [October 7, 2019, 1:44pm UTC](https://discuss.elastic.co/t/elasticsearch-socket-block-or-timeout/202545 "2019-10-07T13:44:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashishtiwari1993](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashishtiwari1993/32/135241_2.png) [@ashishtiwari1993](https://discuss.elastic.co/u/ashishtiwari1993)\
**Post date:** [October 7, 2019, 1:44pm UTC](https://discuss.elastic.co/t/elasticsearch-socket-block-or-timeout/202545/1 "2019-10-07T13:44:28Z")

</div>

Hi Team,

**Cluster Specification:**

```
ES version - 6.2.2
Nodes : 3 (true => master, data, ingest)
Heap : 30 GB per node
RAM : 128 GB , 64 GB, 64 GB
Core: 24
Disk Available : approx 200 GB
indexes - 169 
Replica - 0
Per index size - 50GB approx (50 cr records)
Hot indexes - 40
shards - 6

```

**Node settings:**

```
indices.memory.index_buffer_size: 50%

thread_pool.index.size : 24
thread_pool.index.queue_size : 10000
thread_pool.bulk.size: 24
thread_pool.bulk.queue_size: 30000
thread_pool.search.size: 50
thread_pool.search.queue_size: 30000

```

**OS settings**

```
/etc/security/limits.conf
elasticsearch soft nproc 4096
elasticsearch hard nproc 4096
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited

```

**Requests:**

```
Indexing : 5k - 6k / sec (Bulk => Insert / update / partial / Few request with script condition, with the batch of few KBs only. with 200 Parallel process )
Searching : 5k - 6k read request (search / count / aggregation Few with script condition)

```

**Problem :** One of the node from ES cluster not gives response till long time. I simply try to hit `curl mynode1.com:9200` . It gives me timeout. After some time it start giving responses.

**Observations** :

1. Whenever any heavy search queries comes, It start blocking one of the node's port 9200.

2. As per slow query log search query is `_search` with `size:1000` and `from:500000` & few matches parameters.

3. Whenever this situation occurs my write / Bulk query becomes slow or getting `{"type":"cluster_block_exception","reason":"blocked by: [SERVICE_UNAVAILABLE\/2\/no master];"}` Although my 2 node keep responding.

4. Read query takes approx 40 + seconds with simple search and write also takes 40 + seconds.

5. Once search queries done then situation becomes normal.

6. Other two server getting timeout exception. **Logs**

7. Also check with Hardware stuff. Nothing looks strange.

I can't find the any reason which causing socket block. Any insights or suggestions will be appreciable guys 🙂

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 9, 2019, 7:23am UTC](https://discuss.elastic.co/t/elasticsearch-socket-block-or-timeout/202545/2 "2019-10-09T07:23:53Z")

</div>

Hey,

it seems you also have fiddled around with other parameters, as from + size can by default cannot exceed 10000. This also has a reason. deep pagination (what you are trying to do) will require a decent amount of memory, which in turn might end up in garbage collection (and that might be the reason for your slowness).

The correct way to do deep pagination is to use [search\_after](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-request-body.html#request-body-search-search-after) or a [scroll search](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-request-body.html#request-body-search-scroll) instead. If you have lots of requests doing this, then search after should be used, as scroll is a point in time snapshot that requires certain resources to be held open.

--Alex

---

<div class="post-metadata">

**Author:** ![ashishtiwari1993](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashishtiwari1993/32/135241_2.png) [@ashishtiwari1993](https://discuss.elastic.co/u/ashishtiwari1993)\
**Post date:** [October 9, 2019, 7:33am UTC](https://discuss.elastic.co/t/elasticsearch-socket-block-or-timeout/202545/3 "2019-10-09T07:33:15Z")

</div>

Thanks Alex for your response. From + size should not be exceed 10k so elasticsearch will load all data (From + size) in heap ? Means there will be 10k data will be load in heap ? And one more doubt how it will impact to my write operations ?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 9, 2019, 1:01pm UTC](https://discuss.elastic.co/t/elasticsearch-socket-block-or-timeout/202545/4 "2019-10-09T13:01:14Z")

</div>

No, it will not load all data in heap.

See [https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html)

---

<div class="post-metadata">

**Author:** ![ashishtiwari1993](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashishtiwari1993/32/135241_2.png) [@ashishtiwari1993](https://discuss.elastic.co/u/ashishtiwari1993)\
**Post date:** [October 9, 2019, 2:31pm UTC](https://discuss.elastic.co/t/elasticsearch-socket-block-or-timeout/202545/5 "2019-10-09T14:31:52Z")

</div>

Ohhh got clearity. I will convert to scroll. But still curious how it will impact my write ?

---

<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:** [November 6, 2019, 2:31pm UTC](https://discuss.elastic.co/t/elasticsearch-socket-block-or-timeout/202545/6 "2019-11-06T14:31:55Z")

</div>

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