# Elasticsearch occasionally slow query problem

**URL:** <https://discuss.elastic.co/t/elasticsearch-occasionally-slow-query-problem/200997>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [September 25, 2019, 9:01am UTC](https://discuss.elastic.co/t/elasticsearch-occasionally-slow-query-problem/200997 "2019-09-25T09:01:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![binzhang](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@binzhang](https://discuss.elastic.co/u/binzhang)\
**Post date:** [September 25, 2019, 9:01am UTC](https://discuss.elastic.co/t/elasticsearch-occasionally-slow-query-problem/200997/1 "2019-09-25T09:01:28Z")

</div>

**Basic configurations** :  
**cluster** : two nodes as master eligible node and data node  
**es version** : 7.2.0  
**jvm heap size** : 31GB per node  
**node memory** : 256GB per node  
**primary/replica shards** : 1/1  
**disk** : 2TB+ per node  
**deploy mode** : docker  
**host system** : debian 8  
**deploy configure** :

- 

```
    docker run -d --name esnode01 \*

```

- 

```
  	-v /home/workspace/elasticsearch/data:/usr/share/elasticsearch/data \*

```

- 

```
  	--ulimit memlock=-1:-1 \*

```

- 

```
  	--ulimit nofile=65535:65535 \*

```

- 

```
  	-p 9200:9200 \*

```

- 

```
  	-p 9300:9300 \*

```

- 

```
  	-e node.name=esnode01 \*

```

- 

```
  	-e node.data=true \*

```

- 

```
  	-e node.master=true \*

```

- 

```
  	-e network.publish_host=$ip01 \*

```

- 

```
  	-e discovery.seed_hosts=$ip02:9300 \*

```

- 

```
  	-e cluster.initial_master_nodes=esnode01,esnode02 \*

```

- 

```
  	-e cluster.name=es-docker-cluster \*

```

- 

```
  	-e bootstrap.memory_lock=true \*

```

- 

```
  	-e "ES_JAVA_OPTS=-Xms31g -Xmx31g" \*

```

- 

```
  	-e http.cors.enabled=true \*

```

- 

```
          -e http.cors.allow-origin=* \*

```

- 

```
  	--restart=always \*

```

- 

```
  	docker.elastic.co/elasticsearch/elasticsearch:7.2.0*

```

**index mappings:**  
{  
"mapping": {  
"properties": {  
"question": {  
"type": "text"  
},  
"update\_time": {  
"type": "date"  
}  
}  
}  
}  
**index docs** : 11k  
**ps:**
  1. column question are chinese words
  2. enabled search slow log  
"index.search.slowlog.level": "debug",  
"index.search.slowlog.threshold.fetch.debug": "5ms",  
"index.search.slowlog.threshold.query.debug": "1ms",

**Query pharse：**  
POST /index\_name/\_search  
{  
"from": 0,  
"size": 50,  
"query": {  
"match": {  
"question": text  
}  
}  
}

**Problem:**  
Most queries cost time \< 20 ms, Occasionally, 'took' field equals from 100ms, 200ms, up to 900+ms..

**Analysis:**  
kibana monitoring shows no high indexing rate, no long gc time, no high system load, no two many segments, even no high search and query lantency;  
search\_slow\_log shows no high took time querys, profile api shows very small query time\_in\_nano

Any advices are appreciated

---

<div class="post-metadata">

**Author:** ![binzhang](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@binzhang](https://discuss.elastic.co/u/binzhang)\
**Post date:** [September 25, 2019, 9:15am UTC](https://discuss.elastic.co/t/elasticsearch-occasionally-slow-query-problem/200997/2 "2019-09-25T09:15:26Z")

</div>

Supplementation:  
no high parallel queries!!!

es monitoring query and fetch time in last 6 hours(unit: ms):

 ![query](https://us1.discourse-cdn.com/elastic/original/3X/2/a/2a9d91f45e9a4a41216b2e300065a7222658c340.png)

es query service took time in last 6 hours(unit: second):

 ![%E8%80%97%E6%97%B6](https://us1.discourse-cdn.com/elastic/original/3X/6/7/6721e76eb49ccdfc735822a0af3e3ef5e6df91aa.png)

---

<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:** [October 23, 2019, 9:16am UTC](https://discuss.elastic.co/t/elasticsearch-occasionally-slow-query-problem/200997/3 "2019-10-23T09:16:01Z")

</div>

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