# Search times out and incurs high CPU

**URL:** https://discuss.elastic.co/t/search-times-out-and-incurs-high-cpu/84759
**Category:** Elasticsearch
**Created:** [May 5, 2017, 4:40pm UTC](https://discuss.elastic.co/t/search-times-out-and-incurs-high-cpu/84759 "2017-05-05T16:40:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Guoxing\_Li](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Guoxing\_Li](https://discuss.elastic.co/u/Guoxing_Li)
#### Post date: [May 5, 2017, 4:40pm UTC](https://discuss.elastic.co/t/search-times-out-and-incurs-high-cpu/84759/1 "2017-05-05T16:40:00Z")

</div>

Hi,  
Our es node is experiencing a search performance problem. A single search query to es (with no other load) could easily time out (30s) and the CPU can go \> 100%. Is it because of the hardware problem? Here are some infos.

ES setup:  
ES version: 5.2.2  
Nodes: 1 node  
Data size: ~8GB, ~800,000 docs  
RAM: 8GB  
CPU: 2 core intel  
Hard drive: non-SSD  
ES heap: ~3.5GB

The search query is with highlighting. It's searching against an index with ~35,000 docs.

Hot threads output:

> <https://gist.github.com/guoxing/d75737f7ceb6fc631b6bfe8aaf6fe94a>

Any help is appreciated.

---

<div class="post-metadata">

### Author: ![Guoxing\_Li](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Guoxing\_Li](https://discuss.elastic.co/u/Guoxing_Li)
#### Post date: [May 12, 2017, 4:46pm UTC](https://discuss.elastic.co/t/search-times-out-and-incurs-high-cpu/84759/2 "2017-05-12T16:46:48Z")

</div>

Anyone shed some light please?

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [May 12, 2017, 5:07pm UTC](https://discuss.elastic.co/t/search-times-out-and-incurs-high-cpu/84759/3 "2017-05-12T17:07:48Z")

</div>

If you highlight many results and looking to highlight multiple fields then the default highlighter is known to be expensive. In an effort to re-create the matching and scoring logic that went into producing each hit it does this pseudo code:

```
for each doc to be highlighted:
    for each field that needs highlighting:
       index field value into a temporary, in-memory index
       run query against in-memory index
       throw away in-memory index

```

You can see some of this in-memory indexing going on in your hot threads.

---

<div class="post-metadata">

### Author: ![Guoxing\_Li](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Guoxing\_Li](https://discuss.elastic.co/u/Guoxing_Li)
#### Post date: [May 12, 2017, 5:55pm UTC](https://discuss.elastic.co/t/search-times-out-and-incurs-high-cpu/84759/4 "2017-05-12T17:55:37Z")

</div>

That does seem like a quite expensive operation. Will try to limit the usage of highlights and see if it helps. 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: [June 9, 2017, 6:06pm UTC](https://discuss.elastic.co/t/search-times-out-and-incurs-high-cpu/84759/5 "2017-06-09T18:06:00Z")

</div>

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