# Nest: Bulk insert and timeout

**URL:** <https://discuss.elastic.co/t/nest-bulk-insert-and-timeout/60641>\
**Category:** Elasticsearch\
**Created:** [September 15, 2016, 7:16pm UTC](https://discuss.elastic.co/t/nest-bulk-insert-and-timeout/60641 "2016-09-15T19:16:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Denis\_Lamanov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/denis_lamanov/32/13111_2.png) [@Denis\_Lamanov](https://discuss.elastic.co/u/Denis_Lamanov)\
**Post date:** [September 15, 2016, 7:16pm UTC](https://discuss.elastic.co/t/nest-bulk-insert-and-timeout/60641/1 "2016-09-15T19:16:05Z")

</div>

Hi guys,

We are using new server with 24 cores, RAID 5, 64 GB RAM  
Have about 70 indices and trying to write data to it using bulk insert(batch size 5k per index)  
But sometimes we have timeouts:

> Invalid NEST response built from a unsuccessful low level call on POST: /index1/message/\_bulk # Audit trail of this API call: - [1] BadResponse: Node: [http://server:9200/](http://server:9200/) Took: 00:01:28.1294390 - [2] MaxTimeoutReached: Took: -736221.10:34:34.9317145 # OriginalException: System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

Could you please explain which timeout we reached and can we tune it?

Thanks

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [September 16, 2016, 9:35am UTC](https://discuss.elastic.co/t/nest-bulk-insert-and-timeout/60641/2 "2016-09-16T09:35:57Z")

</div>

> [@Denis\_Lamanov](#):
>
> Have about 70 indices

70 indices, or 70 shards in one index?

The default request timeout for the client is set to 1 minute and can be changed globally in configuration:

```
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings = new ConnectionSettings(pool)
        // set the request timeout to 3 minutes
    .RequestTimeout(TimeSpan.FromMinutes(3));

```

Alternatively, you can set a request timeout on a **per** request basis, so for example, set a longer one on your bulk requests

```
client.Bulk(b => b
    .CreateMany(people)
    .RequestConfiguration(r => r
        .RequestTimeout(TimeSpan.FromMinutes(2))
    )
);

```

---

<div class="post-metadata">

**Author:** ![Denis\_Lamanov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/denis_lamanov/32/13111_2.png) [@Denis\_Lamanov](https://discuss.elastic.co/u/Denis_Lamanov)\
**Post date:** [September 16, 2016, 1:37pm UTC](https://discuss.elastic.co/t/nest-bulk-insert-and-timeout/60641/3 "2016-09-16T13:37:22Z")

</div>

Hi Russ,

> [@forloop](#):
>
> 70 indices, or 70 shards in one index?

70 indices, each has 1 shard

I guess the issue related to reason we are using spinned HDD  
We changed config to:

> index.merge.scheduler.max\_thread\_count: 1  
> http.max\_content\_length: 256mb  
> index.number\_of\_shards: 1

> threadpool.bulk.size: 600  
> threadpool.bulk.queue\_size: 5000

> index.refresh\_interval: 30s  
> index.translog.flush\_threshold\_ops: 500000  
> indices.memory.index\_buffer\_size: 30%

and it helped.

Thanks

---

<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 5, 2017, 10:19pm UTC](https://discuss.elastic.co/t/nest-bulk-insert-and-timeout/60641/4 "2017-07-05T22:19:39Z")

</div>


