# Slow ElasticSearch queries and huge load

**URL:** https://discuss.elastic.co/t/slow-elasticsearch-queries-and-huge-load/9987
**Category:** Elasticsearch
**Created:** [December 7, 2012, 2:45pm UTC](https://discuss.elastic.co/t/slow-elasticsearch-queries-and-huge-load/9987 "2012-12-07T14:45:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Piotr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piotr/32/2587_2.png) [@Piotr](https://discuss.elastic.co/u/Piotr)
#### Post date: [December 7, 2012, 2:45pm UTC](https://discuss.elastic.co/t/slow-elasticsearch-queries-and-huge-load/9987/1 "2012-12-07T14:45:54Z")

</div>

Hello,

I saw already some topics about the performance of ES here, but none of  
them answered any of my questions. I would like to use ES for a search  
engine. It looks really great how easy it is to create new nodes, connect  
them together into clusters, make replicas etc. comparing to Solr or  
Sphinx. I've created 3 nodes with 3 shards and 1 replica (+1 ElasticSearch  
for balancing only). Each node is run with such JVM params:

-Xms5g -Xmx5g -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC  
-XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75  
-XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError  
-XX:+UseTLAB -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

Machine has 16GB or RAM, 4 cores Intel i5 processor @ 3.40 GHz

There is only one index with one mapping which look like that:

{  
"files" : {  
"groups" : {  
"\_source" : {  
"enabled" : false  
},  
"properties" : {  
"id" : {  
"type" : "string",  
"index" : "no",  
"store" : "yes"  
},  
"clicks" : {  
"type" : "integer"  
},  
"date\_added" : {  
"type" : "long"  
},  
"desc" : {  
"type" : "string",  
"term\_vector" : "with\_positions\_offsets"  
},  
"extension\_attr" : {  
"type" : "short"  
},  
"group\_id" : {  
"type" : "long",  
"store" : "yes"  
},  
"host" : {  
"type" : "string",  
"term\_vector" : "with\_positions\_offsets"  
},  
"hosting\_id" : {  
"type" : "integer"  
},  
"name" : {  
"type" : "string",  
"boost" : 3.0,  
"term\_vector" : "with\_positions\_offsets"  
},  
"size" : {  
"type" : "integer"  
},  
"source\_title" : {  
"type" : "string",  
"term\_vector" : "with\_positions\_offsets"  
},  
"source\_url" : {  
"type" : "string",  
"term\_vector" : "with\_positions\_offsets"  
}  
}  
}  
}  
}

In this index there are around 30M records for both ElasticSearch and  
Sphinx Search. Whether Sphinx on the same machine and single node makes  
response for a MATCH query like MATCH('test') takes around 0.14s then in  
ElasticSearch it's 2,3s. I'm surprised of these results. I'm not sure if  
it's normal time for a query which does not reside in cache. I'm thinking  
if there's any possibility to tune ES.

--

---

<div class="post-metadata">

### Author: ![Piotr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piotr/32/2587_2.png) [@Piotr](https://discuss.elastic.co/u/Piotr)
#### Post date: [December 10, 2012, 7:49am UTC](https://discuss.elastic.co/t/slow-elasticsearch-queries-and-huge-load/9987/2 "2012-12-10T07:49:46Z")

</div>

Forgot to put the exact query:

{  
"query": {  
"custom\_score": {  
"query": {  
"query\_string": {  
"default\_field": "\_all",  
"default\_operator": "and",  
"query": "test"  
}  
}  
}  
},  
"fields": [  
"group\_id",  
"name",  
"date\_added"  
],  
"from": 0,  
"size": 50,  
"sort": ,  
"facets": {}  
}

Is this normal to have responses around 2s for such a query?

W dniu piątek, 7 grudnia 2012 15:45:54 UTC+1 użytkownik Piotr napisał:

> Hello,
> 
> I saw already some topics about the performance of ES here, but none of  
> them answered any of my questions. I would like to use ES for a search  
> engine. It looks really great how easy it is to create new nodes, connect  
> them together into clusters, make replicas etc. comparing to Solr or  
> Sphinx. I've created 3 nodes with 3 shards and 1 replica (+1 Elasticsearch  
> for balancing only). Each node is run with such JVM params:
> 
> -Xms5g -Xmx5g -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC  
> -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75  
> -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError  
> -XX:+UseTLAB -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
> 
> Machine has 16GB or RAM, 4 cores Intel i5 processor @ 3.40 GHz
> 
> There is only one index with one mapping which look like that:
> 
> {  
> "files" : {  
> "groups" : {  
> "\_source" : {  
> "enabled" : false  
> },  
> "properties" : {  
> "id" : {  
> "type" : "string",  
> "index" : "no",  
> "store" : "yes"  
> },  
> "clicks" : {  
> "type" : "integer"  
> },  
> "date\_added" : {  
> "type" : "long"  
> },  
> "desc" : {  
> "type" : "string",  
> "term\_vector" : "with\_positions\_offsets"  
> },  
> "extension\_attr" : {  
> "type" : "short"  
> },  
> "group\_id" : {  
> "type" : "long",  
> "store" : "yes"  
> },  
> "host" : {  
> "type" : "string",  
> "term\_vector" : "with\_positions\_offsets"  
> },  
> "hosting\_id" : {  
> "type" : "integer"  
> },  
> "name" : {  
> "type" : "string",  
> "boost" : 3.0,  
> "term\_vector" : "with\_positions\_offsets"  
> },  
> "size" : {  
> "type" : "integer"  
> },  
> "source\_title" : {  
> "type" : "string",  
> "term\_vector" : "with\_positions\_offsets"  
> },  
> "source\_url" : {  
> "type" : "string",  
> "term\_vector" : "with\_positions\_offsets"  
> }  
> }  
> }  
> }  
> }
> 
> In this index there are around 30M records for both Elasticsearch and  
> Sphinx Search. Whether Sphinx on the same machine and single node makes  
> response for a MATCH query like MATCH('test') takes around 0.14s then in  
> Elasticsearch it's 2,3s. I'm surprised of these results. I'm not sure if  
> it's normal time for a query which does not reside in cache. I'm thinking  
> if there's any possibility to tune ES.

--

---

<div class="post-metadata">

### Author: ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)
#### Post date: [December 10, 2012, 10:34pm UTC](https://discuss.elastic.co/t/slow-elasticsearch-queries-and-huge-load/9987/3 "2012-12-10T22:34:22Z")

</div>

There could be many reasons for this and one would have to dig in. The  
most basic thing that comes to mind is that on this 1 server you likely  
have 5 index shards (default), which is pointless and adds overhead. Make  
it 1, reindex, and then try. I'd love to see the before and after  
comparison.

## Otis

ELASTICSEARCH Performance Monitoring - [Sematext Monitoring | Infrastructure Monitoring Service](http://sematext.com/spm/index.html)  
Search Analytics - [Cloud Monitoring Tools & Services | Sematext](http://sematext.com/search-analytics/index.html)

On Friday, December 7, 2012 9:45:54 AM UTC-5, Piotr wrote:

> Hello,
> 
> I saw already some topics about the performance of ES here, but none of  
> them answered any of my questions. I would like to use ES for a search  
> engine. It looks really great how easy it is to create new nodes, connect  
> them together into clusters, make replicas etc. comparing to Solr or  
> Sphinx. I've created 3 nodes with 3 shards and 1 replica (+1 Elasticsearch  
> for balancing only). Each node is run with such JVM params:
> 
> -Xms5g -Xmx5g -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC  
> -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75  
> -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError  
> -XX:+UseTLAB -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
> 
> Machine has 16GB or RAM, 4 cores Intel i5 processor @ 3.40 GHz
> 
> There is only one index with one mapping which look like that:
> 
> {  
> "files" : {  
> "groups" : {  
> "\_source" : {  
> "enabled" : false  
> },  
> "properties" : {  
> "id" : {  
> "type" : "string",  
> "index" : "no",  
> "store" : "yes"  
> },  
> "clicks" : {  
> "type" : "integer"  
> },  
> "date\_added" : {  
> "type" : "long"  
> },  
> "desc" : {  
> "type" : "string",  
> "term\_vector" : "with\_positions\_offsets"  
> },  
> "extension\_attr" : {  
> "type" : "short"  
> },  
> "group\_id" : {  
> "type" : "long",  
> "store" : "yes"  
> },  
> "host" : {  
> "type" : "string",  
> "term\_vector" : "with\_positions\_offsets"  
> },  
> "hosting\_id" : {  
> "type" : "integer"  
> },  
> "name" : {  
> "type" : "string",  
> "boost" : 3.0,  
> "term\_vector" : "with\_positions\_offsets"  
> },  
> "size" : {  
> "type" : "integer"  
> },  
> "source\_title" : {  
> "type" : "string",  
> "term\_vector" : "with\_positions\_offsets"  
> },  
> "source\_url" : {  
> "type" : "string",  
> "term\_vector" : "with\_positions\_offsets"  
> }  
> }  
> }  
> }  
> }
> 
> In this index there are around 30M records for both Elasticsearch and  
> Sphinx Search. Whether Sphinx on the same machine and single node makes  
> response for a MATCH query like MATCH('test') takes around 0.14s then in  
> Elasticsearch it's 2,3s. I'm surprised of these results. I'm not sure if  
> it's normal time for a query which does not reside in cache. I'm thinking  
> if there's any possibility to tune ES.

--

---

<div class="post-metadata">

### Author: ![karmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karmi/32/44951_2.png) [@karmi](https://discuss.elastic.co/u/karmi)
#### Post date: [December 11, 2012, 9:16am UTC](https://discuss.elastic.co/t/slow-elasticsearch-queries-and-huge-load/9987/4 "2012-12-11T09:16:08Z")

</div>

> In this index there are around 30M records for both Elasticsearch and  
> Sphinx Search.  
> Whether Sphinx on the same machine and single node makes response for a  
> MATCH query like MATCH('test') takes around 0.14s then in Elasticsearch  
> it's 2,3s.  
> I'm surprised of these results. I'm not sure if it's normal time for a  
> query which does not reside in cache.

First, it's important to understand if you're interested in numbers for a  
"cold" system, or a "warmed up" system, where Elasticsearch and OS caches  
are filled and used. Usually, the "cold" numbers are not of much use as a  
guideline for production use; note, that recent Elasticsearch versions come  
with a Warmer API [1](http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers.html).

Second, just send the same request repeatedly, and observe if the `took`  
time and the response time is decreasing and how much. Observe  
Elasticsearch with a tool such as Paramedic or BigDesk to visually check  
the amount of memory needed, CPU, etc.

Third, as Otis hints, Elasticsearch by default splits your index into 5  
shards (in effect, separate Lucene indices). It may be a contributing  
factor, try to create the index with one shard only and no replicas:

```
curl -X PUT localhost:9200/my-index/_settings -d '{ "index" : 

```

{"number\_of\_shards": 1, "number\_of\_replicas": 0} }'

Last, Elasticsearch can log slow queries [2](http://www.elasticsearch.org/guide/reference/index-modules/slowlog.html), when you start testing more  
complex queries, it may be useful for you to see the `took` time for each  
query.

Karel

--

---

<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 6, 2017, 3:00am UTC](https://discuss.elastic.co/t/slow-elasticsearch-queries-and-huge-load/9987/5 "2017-07-06T03:00:23Z")

</div>


