# Timing out while indexing

**URL:** https://discuss.elastic.co/t/timing-out-while-indexing/4486
**Category:** Elasticsearch
**Created:** [May 27, 2011, 12:09am UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486 "2011-05-27T00:09:25Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Ian\_Eure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_eure/32/3157_2.png) [@Ian\_Eure](https://discuss.elastic.co/u/Ian_Eure)
#### Post date: [May 27, 2011, 12:09am UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/1 "2011-05-27T00:09:25Z")

</div>

I'm evaluating ElasticSearch as a replacement for Solr, as my data is  
getting too large for Solr to cope with comfortably.

I'm importing ~19m documents, each of which is ~512 bytes. I'm using a  
two-node ElasticSearch 0.16.1 cluster on EC2 m1.large instances.  
They're running on Ubuntu Maverick servers, with Sun Java 1.6.0\_21-  
b06. I wrote a bulk import script which uses pyes over HTTP. I'm using  
the default pyes chunk size of 400 documents.

After indexing around 3m documents, connections to ES time out:

File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
py2.6.egg/pyes/es.py", line 634, in index  
self.flush\_bulk()  
File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
py2.6.egg/pyes/es.py", line 660, in flush\_bulk  
self.force\_bulk()  
File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
py2.6.egg/pyes/es.py", line 668, in force\_bulk  
self.\_send\_request("POST", "/\_bulk", self.bulk\_data.getvalue())  
File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
py2.6.egg/pyes/es.py", line 205, in \_send\_request  
response = self.connection.execute(request)  
File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
py2.6.egg/pyes/connection\_http.py", line 167, in \_client\_call  
return getattr(conn.client, attr)(\*args, \*\*kwargs)  
File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
py2.6.egg/pyes/connection\_http.py", line 59, in execute  
response =  
self.client.urlopen(Method.\_VALUES\_TO\_NAMES[request.method], uri,  
body=request.body, headers=request.headers)  
File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
py2.6.egg/pyes/urllib3/connectionpool.py", line 286, in urlopen  
raise TimeoutError("Request timed out after %f seconds" %  
self.timeout)  
pyes.urllib3.connectionpool.TimeoutError: Request timed out after  
5.000000 seconds

There was nothing in the logs at all, so I turned on whatever debug  
settings I could find and tried again. Got the same result, and I  
didn't see much in the logs. The only thing that looked suspicious was  
this:

[2011-05-26 23:46:53,695][DEBUG][index.merge.scheduler] [Marko,  
Cain] [canonical][0] merge [\_5yf] done, took [27.3s]

However, this appears a many times (I count 177, but this is for more  
than just the import which died) prior to this last time, and none of  
those seemed to have an effect.

I'm importing on the same box as I'm running ElasticSearch, so this is  
just over localhost; I doubt this is a network issue.

I don't know what's going on, and I'd like to get this working. I  
asked on IRC, but nobody responded. How do I go about diagnosing and  
solving this problem?

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [May 27, 2011, 11:29am UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/2 "2011-05-27T11:29:23Z")

</div>

Heya,

I see that the timeout is set to 5 seconds. It might be that the bulk indexing is creating such a load that it takes more than 5 seconds for some operations (m1.large is not really strong, and IO is probably bad). Not sure also what load the client indexing system that is running on the same machine is generating.

The merge logging you see are logs indicating the internal merge process happening in Lucene (the internal process of maintaing the index files). This merge process can be heavy IO wise.

I would suggest increasing the timeout value, just to see if you do manage to finish your indexing process. You can also try and optimize the index for bulk indexing using the update settings API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html) (see at the bottom).

On Friday, May 27, 2011 at 3:09 AM, Ian Eure wrote:

> I'm evaluating Elasticsearch as a replacement for Solr, as my data is  
> getting too large for Solr to cope with comfortably.
> 
> I'm importing ~19m documents, each of which is ~512 bytes. I'm using a  
> two-node Elasticsearch 0.16.1 cluster on EC2 m1.large instances.  
> They're running on Ubuntu Maverick servers, with Sun Java 1.6.0\_21-  
> b06. I wrote a bulk import script which uses pyes over HTTP. I'm using  
> the default pyes chunk size of 400 documents.
> 
> After indexing around 3m documents, connections to ES time out:
> 
> File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> py2.6.egg/pyes/es.py", line 634, in index  
> self.flush\_bulk()  
> File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> py2.6.egg/pyes/es.py", line 660, in flush\_bulk  
> self.force\_bulk()  
> File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> py2.6.egg/pyes/es.py", line 668, in force\_bulk  
> self.\_send\_request("POST", "/\_bulk", self.bulk\_data.getvalue())  
> File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> py2.6.egg/pyes/es.py", line 205, in \_send\_request  
> response = self.connection.execute(request)  
> File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> py2.6.egg/pyes/connection\_http.py", line 167, in \_client\_call  
> return getattr(conn.client, attr)(\*args, \*\*kwargs)  
> File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> py2.6.egg/pyes/connection\_http.py", line 59, in execute  
> response =  
> self.client.urlopen(Method.\_VALUES\_TO\_NAMES[request.method], uri,  
> body=request.body, headers=request.headers)  
> File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> py2.6.egg/pyes/urllib3/connectionpool.py", line 286, in urlopen  
> raise TimeoutError("Request timed out after %f seconds" %  
> self.timeout)  
> pyes.urllib3.connectionpool.TimeoutError: Request timed out after  
> 5.000000 seconds
> 
> There was nothing in the logs at all, so I turned on whatever debug  
> settings I could find and tried again. Got the same result, and I  
> didn't see much in the logs. The only thing that looked suspicious was  
> this:
> 
> [2011-05-26 23:46:53,695][DEBUG][index.merge.scheduler] [Marko,  
> Cain] [canonical][0] merge [\_5yf] done, took [27.3s]
> 
> However, this appears a many times (I count 177, but this is for more  
> than just the import which died) prior to this last time, and none of  
> those seemed to have an effect.
> 
> I'm importing on the same box as I'm running Elasticsearch, so this is  
> just over localhost; I doubt this is a network issue.
> 
> I don't know what's going on, and I'd like to get this working. I  
> asked on IRC, but nobody responded. How do I go about diagnosing and  
> solving this problem?

---

<div class="post-metadata">

### Author: ![Ian\_Eure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_eure/32/3157_2.png) [@Ian\_Eure](https://discuss.elastic.co/u/Ian_Eure)
#### Post date: [May 27, 2011, 4:15pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/3 "2011-05-27T16:15:48Z")

</div>

On May 27, 2011, at 4:29 AM, Shay Banon wrote:

> Heya,
> 
> I see that the timeout is set to 5 seconds. It might be that the bulk indexing is creating such a load that it takes more than 5 seconds for some operations (m1.large is not really strong, and IO is probably bad). Not sure also what load the client indexing system that is running on the same machine is generating.
> 
> The merge logging you see are logs indicating the internal merge process happening in Lucene (the internal process of maintaing the index files). This merge process can be heavy IO wise.

Okay — But it happens hundreds of other times, for similar lengths of time, and none of those cause timeouts. I'm not convinced that this is the source of the problem, it's just the only thing I saw in the logs that looked interesting.

> ```
> I would suggest increasing the timeout value, just to see if you do manage to finish your indexing process. You can also try and optimize the index for bulk indexing using the update settings API: http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html (see at the bottom).
> 
> ```

What I really want is to identify the source of the timeouts, rather than work around the symptom. There's just no way I'm putting anything into production that exhibits stalls like that without fully understanding the circumstances that trigger it and being confident that it isn't going to happen under normal load.

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [May 27, 2011, 8:52pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/4 "2011-05-27T20:52:49Z")

</div>

Hi,

just my 2 cents. I'm indexing 17.8 million documents with bulk  
indexing, to 3 ES nodes, with the Java API, but pyes should be  
comparable. The bulk size is 300 docs of ~10k each and 12 threads in  
parallel. It is normal that Lucene steps in with large amounts of I/O  
load from time to time. On the nodes (RHEL6) I see spikes up to a load  
of 10, 20, 30. Unfortunately the frequence and intensity is not really  
predictable. Anyway, you should not bother about the Lucene internals.  
Therefore, the bulk indexing needs some dynamic throttling, in order  
to adapt to current ES bulk API response times. I have added a  
callback mechanism with an upper limit of 30 open bulks, so if  
response times get longer, the more the indexer threads have to wait.  
It's normal to observe response times up to 20 seconds at Lucene I/O  
work time. I found 30 max bulk jobs a sweet spot in my case, but ymmv.  
It depends on your memory resource organization in the indexer process  
and ES node indexing throughput. A more general solution would be  
dynamic throttling on the basis of some reliable throughput statistics  
summed up from the nodes, but these are not available (yet).

Jörg

On May 27, 1:29 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Heya,
> 
> I see that the timeout is set to 5 seconds. It might be that the bulk indexing is creating such a load that it takes more than 5 seconds for some operations (m1.large is not really strong, and IO is probably bad). Not sure also what load the client indexing system that is running on the same machine is generating.
> 
> The merge logging you see are logs indicating the internal merge process happening in Lucene (the internal process of maintaing the index files). This merge process can be heavy IO wise.
> 
> I would suggest increasing the timeout value, just to see if you do manage to finish your indexing process. You can also try and optimize the index for bulk indexing using the update settings API:[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-update)...(see at the bottom).
> 
> On Friday, May 27, 2011 at 3:09 AM, Ian Eure wrote:
> 
> > I'm evaluating Elasticsearch as a replacement for Solr, as my data is  
> > getting too large for Solr to cope with comfortably.
> 
> > I'm importing ~19m documents, each of which is ~512 bytes. I'm using a  
> > two-node Elasticsearch 0.16.1 cluster on EC2 m1.large instances.  
> > They're running on Ubuntu Maverick servers, with Sun Java 1.6.0\_21-  
> > b06. I wrote a bulk import script which uses pyes over HTTP. I'm using  
> > the default pyes chunk size of 400 documents.
> 
> > After indexing around 3m documents, connections to ES time out:
> 
> > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > py2.6.egg/pyes/es.py", line 634, in index  
> > self.flush\_bulk()  
> > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > py2.6.egg/pyes/es.py", line 660, in flush\_bulk  
> > self.force\_bulk()  
> > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > py2.6.egg/pyes/es.py", line 668, in force\_bulk  
> > self.\_send\_request("POST", "/\_bulk", self.bulk\_data.getvalue())  
> > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > py2.6.egg/pyes/es.py", line 205, in \_send\_request  
> > response = self.connection.execute(request)  
> > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > py2.6.egg/pyes/connection\_http.py", line 167, in \_client\_call  
> > return getattr(conn.client, attr)(\*args, \*\*kwargs)  
> > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > py2.6.egg/pyes/connection\_http.py", line 59, in execute  
> > response =  
> > self.client.urlopen(Method.\_VALUES\_TO\_NAMES[request.method], uri,  
> > body=request.body, headers=request.headers)  
> > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > py2.6.egg/pyes/urllib3/connectionpool.py", line 286, in urlopen  
> > raise TimeoutError("Request timed out after %f seconds" %  
> > self.timeout)  
> > pyes.urllib3.connectionpool.TimeoutError: Request timed out after  
> > 5.000000 seconds
> 
> > There was nothing in the logs at all, so I turned on whatever debug  
> > settings I could find and tried again. Got the same result, and I  
> > didn't see much in the logs. The only thing that looked suspicious was  
> > this:
> 
> > [2011-05-26 23:46:53,695][DEBUG][index.merge.scheduler] [Marko,  
> > Cain] [canonical][0] merge [\_5yf] done, took [27.3s]
> 
> > However, this appears a many times (I count 177, but this is for more  
> > than just the import which died) prior to this last time, and none of  
> > those seemed to have an effect.
> 
> > I'm importing on the same box as I'm running Elasticsearch, so this is  
> > just over localhost; I doubt this is a network issue.
> 
> > I don't know what's going on, and I'd like to get this working. I  
> > asked on IRC, but nobody responded. How do I go about diagnosing and  
> > solving this problem?

---

<div class="post-metadata">

### Author: ![Martijn\_Laarman\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martijn_laarman_2/32/2033_2.png) [@Martijn\_Laarman\_2](https://discuss.elastic.co/u/Martijn_Laarman_2)
#### Post date: [May 27, 2011, 10:06pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/5 "2011-05-27T22:06:01Z")

</div>

My 2 cents as well

NEST supports builtin semaphoring of connections for this reason

See  
[https://github.com/Mpdreamz/NEST/blob/master/src/HackerNews.Indexer/Program.cs](https://github.com/Mpdreamz/NEST/blob/master/src/HackerNews.Indexer/Program.cs)

For an approach that chops a large data set in small async bulk inserts  
using a maximum number of open connections at a time (others are queued to  
wait). This really speeds up indexing but there does seem to be a magic spot  
after which things start to deteriate.

@kimchy would it help if we could control elasticsearch's auto-commit ?  
specifying a single commit after we're done with out bulk inserts to lower  
lucene's segment merging ?

On Fri, May 27, 2011 at 10:52 PM, jprante [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> Hi,
> 
> just my 2 cents. I'm indexing 17.8 million documents with bulk  
> indexing, to 3 ES nodes, with the Java API, but pyes should be  
> comparable. The bulk size is 300 docs of ~10k each and 12 threads in  
> parallel. It is normal that Lucene steps in with large amounts of I/O  
> load from time to time. On the nodes (RHEL6) I see spikes up to a load  
> of 10, 20, 30. Unfortunately the frequence and intensity is not really  
> predictable. Anyway, you should not bother about the Lucene internals.  
> Therefore, the bulk indexing needs some dynamic throttling, in order  
> to adapt to current ES bulk API response times. I have added a  
> callback mechanism with an upper limit of 30 open bulks, so if  
> response times get longer, the more the indexer threads have to wait.  
> It's normal to observe response times up to 20 seconds at Lucene I/O  
> work time. I found 30 max bulk jobs a sweet spot in my case, but ymmv.  
> It depends on your memory resource organization in the indexer process  
> and ES node indexing throughput. A more general solution would be  
> dynamic throttling on the basis of some reliable throughput statistics  
> summed up from the nodes, but these are not available (yet).
> 
> Jörg
> 
> On May 27, 1:29 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Heya,
> > 
> > I see that the timeout is set to 5 seconds. It might be that the bulk  
> > indexing is creating such a load that it takes more than 5 seconds for some  
> > operations (m1.large is not really strong, and IO is probably bad). Not sure  
> > also what load the client indexing system that is running on the same  
> > machine is generating.
> > 
> > The merge logging you see are logs indicating the internal merge process  
> > happening in Lucene (the internal process of maintaing the index files).  
> > This merge process can be heavy IO wise.
> > 
> > I would suggest increasing the timeout value, just to see if you do  
> > manage to finish your indexing process. You can also try and optimize the  
> > index for bulk indexing using the update settings API:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-update)...(seeat the bottom).
> > 
> > On Friday, May 27, 2011 at 3:09 AM, Ian Eure wrote:
> > 
> > > I'm evaluating Elasticsearch as a replacement for Solr, as my data is  
> > > getting too large for Solr to cope with comfortably.
> > 
> > > I'm importing ~19m documents, each of which is ~512 bytes. I'm using a  
> > > two-node Elasticsearch 0.16.1 cluster on EC2 m1.large instances.  
> > > They're running on Ubuntu Maverick servers, with Sun Java 1.6.0\_21-  
> > > b06. I wrote a bulk import script which uses pyes over HTTP. I'm using  
> > > the default pyes chunk size of 400 documents.
> > 
> > > After indexing around 3m documents, connections to ES time out:
> > 
> > > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > > py2.6.egg/pyes/es.py", line 634, in index  
> > > self.flush\_bulk()  
> > > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > > py2.6.egg/pyes/es.py", line 660, in flush\_bulk  
> > > self.force\_bulk()  
> > > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > > py2.6.egg/pyes/es.py", line 668, in force\_bulk  
> > > self.\_send\_request("POST", "/\_bulk", self.bulk\_data.getvalue())  
> > > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > > py2.6.egg/pyes/es.py", line 205, in \_send\_request  
> > > response = self.connection.execute(request)  
> > > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > > py2.6.egg/pyes/connection\_http.py", line 167, in \_client\_call  
> > > return getattr(conn.client, attr)(\*args, \*\*kwargs)  
> > > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > > py2.6.egg/pyes/connection\_http.py", line 59, in execute  
> > > response =  
> > > self.client.urlopen(Method.\_VALUES\_TO\_NAMES[request.method], uri,  
> > > body=request.body, headers=request.headers)  
> > > File "/home/ieure/bulkload/lib/python2.6/site-packages/pyes-0.15.0-  
> > > py2.6.egg/pyes/urllib3/connectionpool.py", line 286, in urlopen  
> > > raise TimeoutError("Request timed out after %f seconds" %  
> > > self.timeout)  
> > > pyes.urllib3.connectionpool.TimeoutError: Request timed out after  
> > > 5.000000 seconds
> > 
> > > There was nothing in the logs at all, so I turned on whatever debug  
> > > settings I could find and tried again. Got the same result, and I  
> > > didn't see much in the logs. The only thing that looked suspicious was  
> > > this:
> > 
> > > [2011-05-26 23:46:53,695][DEBUG][index.merge.scheduler] [Marko,  
> > > Cain] [canonical][0] merge [\_5yf] done, took [27.3s]
> > 
> > > However, this appears a many times (I count 177, but this is for more  
> > > than just the import which died) prior to this last time, and none of  
> > > those seemed to have an effect.
> > 
> > > I'm importing on the same box as I'm running Elasticsearch, so this is  
> > > just over localhost; I doubt this is a network issue.
> > 
> > > I don't know what's going on, and I'd like to get this working. I  
> > > asked on IRC, but nobody responded. How do I go about diagnosing and  
> > > solving this problem?

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [May 28, 2011, 8:46am UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/6 "2011-05-28T08:46:16Z")

</div>

On Friday, May 27, 2011 at 7:15 PM, Ian Eure wrote:

> On May 27, 2011, at 4:29 AM, Shay Banon wrote:
> 
> > Heya,
> > 
> > I see that the timeout is set to 5 seconds. It might be that the bulk indexing is creating such a load that it takes more than 5 seconds for some operations (m1.large is not really strong, and IO is probably bad). Not sure also what load the client indexing system that is running on the same machine is generating.
> > 
> > The merge logging you see are logs indicating the internal merge process happening in Lucene (the internal process of maintaing the index files). This merge process can be heavy IO wise.  
> > Okay — But it happens hundreds of other times, for similar lengths of time, and none of those cause timeouts. I'm not convinced that this is the source of the problem, it's just the only thing I saw in the logs that looked interesting.
> 
> > I would suggest increasing the timeout value, just to see if you do manage to finish your indexing process. You can also try and optimize the index for bulk indexing using the update settings API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html) (see at the bottom).  
> > What I really want is to identify the source of the timeouts, rather than work around the symptom. There's just no way I'm putting anything into production that exhibits stalls like that without fully understanding the circumstances that trigger it and being confident that it isn't going to happen under normal load.  
> > Thats why I said try, I don't know why you get timeouts, or even what this timeout indicates in pyes (maybe aparo can help), i.e. is it a timeout on sending a request, or on connection. I have no idea how your indexing code looks like, and what it does. Is it opening a new connection each time or not (really, localhost is not relevant, it is still a socket)? How many threads / processes do the indexing? Into how many indices? How many shards / replicas do you set for the index?

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [May 28, 2011, 9:01am UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/7 "2011-05-28T09:01:47Z")

</div>

One more thing, how big are the docs? A couple of months ago I helped chase down a similar case (the user was using pyes as well) where suddenly it would timeout, and an average size of docs ~150k. And we found out that every once in a while, there was a doc of ~10mb. And once several of those got into the same bulk, obviously indexing will be slower.

On Saturday, May 28, 2011 at 11:46 AM, Shay Banon wrote:

> On Friday, May 27, 2011 at 7:15 PM, Ian Eure wrote:
> 
> > On May 27, 2011, at 4:29 AM, Shay Banon wrote:
> > 
> > > Heya,
> > > 
> > > I see that the timeout is set to 5 seconds. It might be that the bulk indexing is creating such a load that it takes more than 5 seconds for some operations (m1.large is not really strong, and IO is probably bad). Not sure also what load the client indexing system that is running on the same machine is generating.
> > > 
> > > The merge logging you see are logs indicating the internal merge process happening in Lucene (the internal process of maintaing the index files). This merge process can be heavy IO wise.  
> > > Okay — But it happens hundreds of other times, for similar lengths of time, and none of those cause timeouts. I'm not convinced that this is the source of the problem, it's just the only thing I saw in the logs that looked interesting.
> > 
> > > I would suggest increasing the timeout value, just to see if you do manage to finish your indexing process. You can also try and optimize the index for bulk indexing using the update settings API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html) (see at the bottom).  
> > > What I really want is to identify the source of the timeouts, rather than work around the symptom. There's just no way I'm putting anything into production that exhibits stalls like that without fully understanding the circumstances that trigger it and being confident that it isn't going to happen under normal load.  
> > > Thats why I said try, I don't know why you get timeouts, or even what this timeout indicates in pyes (maybe aparo can help), i.e. is it a timeout on sending a request, or on connection. I have no idea how your indexing code looks like, and what it does. Is it opening a new connection each time or not (really, localhost is not relevant, it is still a socket)? How many threads / processes do the indexing? Into how many indices? How many shards / replicas do you set for the index?

---

<div class="post-metadata">

### Author: ![Ian\_Eure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_eure/32/3157_2.png) [@Ian\_Eure](https://discuss.elastic.co/u/Ian_Eure)
#### Post date: [May 31, 2011, 8:06pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/8 "2011-05-31T20:06:38Z")

</div>

On May 28, 2011, at 1:46 AM, Shay Banon wrote:

> On Friday, May 27, 2011 at 7:15 PM, Ian Eure wrote:
> 
> > On May 27, 2011, at 4:29 AM, Shay Banon wrote:
> > 
> > > Heya,
> > > 
> > > I see that the timeout is set to 5 seconds. It might be that the bulk indexing is creating such a load that it takes more than 5 seconds for some operations (m1.large is not really strong, and IO is probably bad). Not sure also what load the client indexing system that is running on the same machine is generating.
> > > 
> > > The merge logging you see are logs indicating the internal merge process happening in Lucene (the internal process of maintaing the index files). This merge process can be heavy IO wise.  
> > > Okay — But it happens hundreds of other times, for similar lengths of time, and none of those cause timeouts. I'm not convinced that this is the source of the problem, it's just the only thing I saw in the logs that looked interesting.
> > 
> > > I would suggest increasing the timeout value, just to see if you do manage to finish your indexing process. You can also try and optimize the index for bulk indexing using the update settings API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html) (see at the bottom).  
> > > What I really want is to identify the source of the timeouts, rather than work around the symptom. There's just no way I'm putting anything into production that exhibits stalls like that without fully understanding the circumstances that trigger it and being confident that it isn't going to happen under normal load.
> 
> Thats why I said try, I don't know why you get timeouts, or even what this timeout indicates in pyes (maybe aparo can help), i.e. is it a timeout on sending a request, or on connection. I have no idea how your indexing code looks like, and what it does. Is it opening a new connection each time or not (really, localhost is not relevant, it is still a socket)? How many threads / processes do the indexing? Into how many indices? How many shards / replicas do you set for the index?

I'd have to dig further, but what I have noticed is when the timeouts happen, the ES process is completely unresponsive. Connection attempts to the health endpoint via curl time out when it's in this state.

This happens using one single-threaded process. It's using HTTP, so unless pyes is doing pipelining internally, it should be one request per batch. The indexer round-robins between the two nodes in the cluster.

One index, one replica, five shards.

On May 28, 2011, at 2:01 AM, Shay Banon wrote:

> One more thing, how big are the docs? A couple of months ago I helped chase down a similar case (the user was using pyes as well) where suddenly it would timeout, and an average size of docs ~150k. And we found out that every once in a while, there was a doc of ~10mb. And once several of those got into the same bulk, obviously indexing will be slower.

> 

They're around 512 bytes each. I don't have hard numbers, but I doubt the size varies significantly. I would be astonished if there was even a single document which was \>10k.

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [May 31, 2011, 8:40pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/9 "2011-05-31T20:40:07Z")

</div>

Which OS are you using in ec2?

On Tuesday, May 31, 2011 at 11:06 PM, Ian Eure wrote:

> On May 28, 2011, at 1:46 AM, Shay Banon wrote:
> 
> > On Friday, May 27, 2011 at 7:15 PM, Ian Eure wrote:
> > 
> > > On May 27, 2011, at 4:29 AM, Shay Banon wrote:
> > > 
> > > > Heya,
> > > > 
> > > > I see that the timeout is set to 5 seconds. It might be that the bulk indexing is creating such a load that it takes more than 5 seconds for some operations (m1.large is not really strong, and IO is probably bad). Not sure also what load the client indexing system that is running on the same machine is generating.
> > > > 
> > > > The merge logging you see are logs indicating the internal merge process happening in Lucene (the internal process of maintaing the index files). This merge process can be heavy IO wise.  
> > > > Okay — But it happens hundreds of other times, for similar lengths of time, and none of those cause timeouts. I'm not convinced that this is the source of the problem, it's just the only thing I saw in the logs that looked interesting.
> > > 
> > > > I would suggest increasing the timeout value, just to see if you do manage to finish your indexing process. You can also try and optimize the index for bulk indexing using the update settings API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html) (see at the bottom).  
> > > > What I really want is to identify the source of the timeouts, rather than work around the symptom. There's just no way I'm putting anything into production that exhibits stalls like that without fully understanding the circumstances that trigger it and being confident that it isn't going to happen under normal load.
> > 
> > Thats why I said try, I don't know why you get timeouts, or even what this timeout indicates in pyes (maybe aparo can help), i.e. is it a timeout on sending a request, or on connection. I have no idea how your indexing code looks like, and what it does. Is it opening a new connection each time or not (really, localhost is not relevant, it is still a socket)? How many threads / processes do the indexing? Into how many indices? How many shards / replicas do you set for the index?  
> > I'd have to dig further, but what I have noticed is when the timeouts happen, the ES process is completely unresponsive. Connection attempts to the health endpoint via curl time out when it's in this state.
> 
> This happens using one single-threaded process. It's using HTTP, so unless pyes is doing pipelining internally, it should be one request per batch. The indexer round-robins between the two nodes in the cluster.
> 
> One index, one replica, five shards.
> 
> On May 28, 2011, at 2:01 AM, Shay Banon wrote:
> 
> > One more thing, how big are the docs? A couple of months ago I helped chase down a similar case (the user was using pyes as well) where suddenly it would timeout, and an average size of docs ~150k. And we found out that every once in a while, there was a doc of ~10mb. And once several of those got into the same bulk, obviously indexing will be slower.
> 
> They're around 512 bytes each. I don't have hard numbers, but I doubt the size varies significantly. I would be astonished if there was even a single document which was \>10k.

---

<div class="post-metadata">

### Author: ![Ian\_Eure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_eure/32/3157_2.png) [@Ian\_Eure](https://discuss.elastic.co/u/Ian_Eure)
#### Post date: [May 31, 2011, 8:49pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/10 "2011-05-31T20:49:38Z")

</div>

On May 31, 2011, at 1:40 PM, Shay Banon wrote:

> Which OS are you using in ec2?

64-bit Ubuntu 10.04 Lucid server.

---

<div class="post-metadata">

### Author: ![Ian\_Eure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_eure/32/3157_2.png) [@Ian\_Eure](https://discuss.elastic.co/u/Ian_Eure)
#### Post date: [May 31, 2011, 9:18pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/11 "2011-05-31T21:18:24Z")

</div>

On May 31, 2011, at 1:40 PM, Shay Banon wrote:

> Which OS are you using in ec2?

I take that back, they're both on 10.10 Maverick.

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [May 31, 2011, 11:05pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/12 "2011-05-31T23:05:34Z")

</div>

Damn, was hoping it was 10.04, which is known to have many problems on ec2 which affect thinks like elasticsearch (and cassandra, and redis). I actually just read a tweet by the redis fellow recommending upgrading to Natty because of 10.10 problems on ec2... .

So, its hard to say. It sounds very similar to what we saw (and took a long time to track) on ec2 with ubuntu 10.04, which was process suddenly hanging for a period of time and not responding.

Another option is that too many sockets are being opened, and the OS is throttling the creation of new sockets. You can check that with netstat (I really need to add a stat for that in ES, mental note!). I saw it easily happening with a simple ruby sample code that did not use http keep alive and heavy indexing.

-shay.banon

On Wednesday, June 1, 2011 at 12:18 AM, Ian Eure wrote:

> On May 31, 2011, at 1:40 PM, Shay Banon wrote:
> 
> > Which OS are you using in ec2?  
> > I take that back, they're both on 10.10 Maverick.

---

<div class="post-metadata">

### Author: ![Ian\_Eure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_eure/32/3157_2.png) [@Ian\_Eure](https://discuss.elastic.co/u/Ian_Eure)
#### Post date: [May 31, 2011, 11:33pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/13 "2011-05-31T23:33:45Z")

</div>

On May 31, 2011, at 4:05 PM, Shay Banon wrote:

> Damn, was hoping it was 10.04, which is known to have many problems on ec2 which affect thinks like elasticsearch (and cassandra, and redis). I actually just read a tweet by the redis fellow recommending upgrading to Natty because of 10.10 problems on ec2... .

Yes, we've encountered this issue before, and migrated away from Lucid.

> So, its hard to say. It sounds very similar to what we saw (and took a long time to track) on ec2 with ubuntu 10.04, which was process suddenly hanging for a period of time and not responding.
> 
> Another option is that too many sockets are being opened, and the OS is throttling the creation of new sockets. You can check that with netstat (I really need to add a stat for that in ES, mental note!). I saw it easily happening with a simple ruby sample code that did not use http keep alive and heavy indexing.

The symptoms don't seem to match up with this. I was able to get Elasticsearch to hang for quite a while, long enough to fire up htop and see that it was sitting there consuming 100% CPU at the same time as connections were timing out. So the problem doesn't seem to be an issue of being IO/socket bound, but being CPU bound to the point where the process cannot respond.

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [May 31, 2011, 11:51pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/14 "2011-05-31T23:51:36Z")

</div>

Ok, then there are several ways we can try and solve this:

1. Track down whats taking this CPU. This will require some low level profiling to see where time is spent.
2. Try and upgrade to a stronger AWS box. All ec2 users I know are running on m1.xlarge (and above).
3. (relates to 1) If you can fire a similar test on a local machine, even on your laptop, and see if you get the same behavior. If it happens there, it will be simpler to try and track it down.

-shay.banon

On Wednesday, June 1, 2011 at 2:33 AM, Ian Eure wrote:

> On May 31, 2011, at 4:05 PM, Shay Banon wrote:
> 
> > Damn, was hoping it was 10.04, which is known to have many problems on ec2 which affect thinks like elasticsearch (and cassandra, and redis). I actually just read a tweet by the redis fellow recommending upgrading to Natty because of 10.10 problems on ec2... .  
> > Yes, we've encountered this issue before, and migrated away from Lucid.
> 
> > So, its hard to say. It sounds very similar to what we saw (and took a long time to track) on ec2 with ubuntu 10.04, which was process suddenly hanging for a period of time and not responding.
> > 
> > Another option is that too many sockets are being opened, and the OS is throttling the creation of new sockets. You can check that with netstat (I really need to add a stat for that in ES, mental note!). I saw it easily happening with a simple ruby sample code that did not use http keep alive and heavy indexing.  
> > The symptoms don't seem to match up with this. I was able to get Elasticsearch to hang for quite a while, long enough to fire up htop and see that it was sitting there consuming 100% CPU at the same time as connections were timing out. So the problem doesn't seem to be an issue of being IO/socket bound, but being CPU bound to the point where the process cannot respond.

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [June 1, 2011, 9:26am UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/15 "2011-06-01T09:26:23Z")

</div>

Hi Ian

> > 
> 
> The symptoms don't seem to match up with this. I was able to get  
> Elasticsearch to hang for quite a while, long enough to fire up htop  
> and see that it was sitting there consuming 100% CPU at the same time  
> as connections were timing out. So the problem doesn't seem to be an  
> issue of being IO/socket bound, but being CPU bound to the point where  
> the process cannot respond.

Was any swap being used? I've seen this same issue while indexing,  
where memory usage grows, then it tries to GC, but that takes a very  
long time because it needs to swap memory in and out from disk in order  
to figure out what it can release.

See bootstrap.mlockall on

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

clint

---

<div class="post-metadata">

### Author: ![colinsurprenant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colinsurprenant/32/14776_2.png) [@colinsurprenant](https://discuss.elastic.co/u/colinsurprenant)
#### Post date: [June 1, 2011, 2:29pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/16 "2011-06-01T14:29:58Z")

</div>

Hi,

I am running multiple nodes on 10.10 using m1.large EC2 instances  
without any problem.

In bin/service/elasticserach.conf I use the following Java mem config:  
set.default.ES\_MIN\_MEM=1024  
set.default.ES\_MAX\_MEM=3072

which I will increase to 2048, 4096

As been said, 10.04 was very problematic. I am sure you know this but,  
if you upgraded from 10.04 to 10.10 you also have to attach the 10.10  
kernel to your ami.

Otherwise, did you say you were using the Bulk API? Have you tried  
testing with the Index API instead and compare behaviours?

Colin

On Wed, Jun 1, 2011 at 5:26 AM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk) wrote:

> Hi Ian
> 
> > > 
> > 
> > The symptoms don't seem to match up with this. I was able to get  
> > Elasticsearch to hang for quite a while, long enough to fire up htop  
> > and see that it was sitting there consuming 100% CPU at the same time  
> > as connections were timing out. So the problem doesn't seem to be an  
> > issue of being IO/socket bound, but being CPU bound to the point where  
> > the process cannot respond.
> 
> Was any swap being used? I've seen this same issue while indexing,  
> where memory usage grows, then it tries to GC, but that takes a very  
> long time because it needs to swap memory in and out from disk in order  
> to figure out what it can release.
> 
> See bootstrap.mlockall on  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/setup/installation.html)
> 
> clint

---

<div class="post-metadata">

### Author: ![Ian\_Eure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_eure/32/3157_2.png) [@Ian\_Eure](https://discuss.elastic.co/u/Ian_Eure)
#### Post date: [June 1, 2011, 5:23pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/17 "2011-06-01T17:23:59Z")

</div>

On Jun 1, 2011, at 2:26 AM, Clinton Gormley wrote:

> Hi Ian
> 
> > > 
> > 
> > The symptoms don't seem to match up with this. I was able to get  
> > Elasticsearch to hang for quite a while, long enough to fire up htop  
> > and see that it was sitting there consuming 100% CPU at the same time  
> > as connections were timing out. So the problem doesn't seem to be an  
> > issue of being IO/socket bound, but being CPU bound to the point where  
> > the process cannot respond.
> 
> Was any swap being used? I've seen this same issue while indexing,  
> where memory usage grows, then it tries to GC, but that takes a very  
> long time because it needs to swap memory in and out from disk in order  
> to figure out what it can release.

No, I'm on EC2, so there is no swap. I'm using the default settings with bin/elasticsearch, so 1gb max heap. With logs set to DEBUG, I see GC activity, and it is not significant — tens of milliseconds per collection.

---

<div class="post-metadata">

### Author: ![Ian\_Eure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_eure/32/3157_2.png) [@Ian\_Eure](https://discuss.elastic.co/u/Ian_Eure)
#### Post date: [June 1, 2011, 5:29pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/18 "2011-06-01T17:29:08Z")

</div>

On Jun 1, 2011, at 7:29 AM, Colin Surprenant wrote:

> Hi,
> 
> I am running multiple nodes on 10.10 using m1.large EC2 instances  
> without any problem.
> 
> In bin/service/elasticserach.conf I use the following Java mem config:  
> set.default.ES\_MIN\_MEM=1024  
> set.default.ES\_MAX\_MEM=3072
> 
> which I will increase to 2048, 4096

I'll increase the heap size and retest.

> As been said, 10.04 was very problematic. I am sure you know this but,  
> if you upgraded from 10.04 to 10.10 you also have to attach the 10.10  
> kernel to your ami.

I didn't upgrade, I just bought up new nodes.

> Otherwise, did you say you were using the Bulk API? Have you tried  
> testing with the Index API instead and compare behaviours?

I am using the bulk API. I could see if I can reproduce with the regular index endpoint using multiple loader processes. Testing it with a single process was unacceptably slow, I could only index 24 docs/sec. Bulk gets me to ~1200/sec. I guess if I use 50 processes, though…

---

<div class="post-metadata">

### Author: ![colinsurprenant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colinsurprenant/32/14776_2.png) [@colinsurprenant](https://discuss.elastic.co/u/colinsurprenant)
#### Post date: [June 1, 2011, 6:41pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/19 "2011-06-01T18:41:28Z")

</div>

> I am using the bulk API. I could see if I can reproduce with the regular index endpoint using multiple loader processes. Testing it with a single process was unacceptably slow, I could only index 24 docs/sec. Bulk gets me to ~1200/sec. I guess if I use 50 processes, though…

using multiple writer threads should easily get you up to a few hundreds/sec.

> No, I'm on EC2, so there is no swap

totally off topic but if you do want swap, you can always add a swapfile.

Colin

---

<div class="post-metadata">

### Author: ![Ian\_Eure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_eure/32/3157_2.png) [@Ian\_Eure](https://discuss.elastic.co/u/Ian_Eure)
#### Post date: [June 1, 2011, 9:12pm UTC](https://discuss.elastic.co/t/timing-out-while-indexing/4486/20 "2011-06-01T21:12:37Z")

</div>

On Jun 1, 2011, at 7:29 AM, Colin Surprenant wrote:

> Hi,
> 
> I am running multiple nodes on 10.10 using m1.large EC2 instances  
> without any problem.
> 
> In bin/service/elasticserach.conf I use the following Java mem config:  
> set.default.ES\_MIN\_MEM=1024  
> set.default.ES\_MAX\_MEM=3072
> 
> which I will increase to 2048, 4096
> 
> As been said, 10.04 was very problematic. I am sure you know this but,  
> if you upgraded from 10.04 to 10.10 you also have to attach the 10.10  
> kernel to your ami.
> 
> Otherwise, did you say you were using the Bulk API? Have you tried  
> testing with the Index API instead and compare behaviours?

Updating to say that I'm seeing the same bad behavior with m1.xlarge instances. I gave Elasticsearch 10gb of RAM and started indexing with the bulk API as I was before. It continues to spike to 100% CPU and my connections time out. However, it's able to respond to the \_cluster endpoints fine.

Things go fine for ~2m documents, then it starts timing out. It gets worse until I hit ~4m, at which point around 50% of my connections time out and have to be retried.

Any more suggestions? I'm all ears. It floors me that I can't even get my data into it. Can I really be the only person who's come up against this?

[Next page](https://discuss.elastic.co/t/timing-out-while-indexing/4486.md?page=2)
