ES with 100% CPU


We're using ES 1.7.5.

Stacks look like this: Method)$NIOFSIndexInput.readInternal(

Our queries are not very complex (Use a few filters), but they also sort on a field that is defined as DocValues (to avoid fielddata memory).

Any way we can improve this?


What's your OS, setting?
Do you have spare ram on that machine?
How often 'few filters' are changed? i.e. is there an opportunity for cache hit?

Most of the filters are cached, 1 or 2 of them are not since they constantly change.
OS is Ubuntu 14.04 is the default, we haven't set anything specific.

Regarding RAM - The machine has 120GB RAM, 30GB of which is used for heap, the rest is used for filesystem cache.

Giving that stacktrace, switching to mmapfs might help to reduce cpu load.

Is it something that can be changed with a restart, or does it require to recreate and reindex the data?

I think I got my answer from here:

It's possible to just restart the cluster for the new settings.
However, something is still a bit unclear - is it OK to run with a mixed configuration? e.g. 1 server running with mmapfs while other servers are running with default? To test the configuration out before rolling it to all of the nodes.

Thanks for the help.

you don't need to reindex. restart is enough.
this independent across nodes, you can experiment with the only one of them .

The setting change made things much worse in terms of IO:

Flush, Refresh & Search - Fetch times all grew by x5 times, some by even x10.


Any other ideas on how to improve sort performance? We're pretty sure that's the root cause.

The puzzle is that, the stack trace doesn't have anything about sorting. Can it happen that query has a kilometre-long "multiterm" query? Do you update docs really much? Does 30G heap are really necessary? Does filesystem cache caches the index files? Another strange thing us that switching niofs to mmap impacts reading, but flush is about writing.

What I see here is that the scorer goes over a lot of docs, and I guess that is because of sorting, not sure if I got that right.

for example, scorer goes through all docs even without sorting at least to count number of hits. But can you confirm that query with sorting takes much more time than same query without sorting (without cache). Btw, what's in that docvalues field? isn't it really long?

From what I understand, when sorting, the scorer goes over all docs (after applying the filter, but before sorting and taking only a number of hits), so it needs to go over all docs that match the query, even if you take only a smaller # of hits.

The value is a timestamp field.

Another example of a stacktrace:

   75.8% (379ms out of 500ms) cpu usage by thread 'elasticsearch[AAA][search][T#22]'
     10/10 snapshots sharing following 22 elements$ConstantWeight.scorer($RandomAccessFilterStrategy.filteredScorer($FilterStrategy.filteredBulkScorer($1.bulkScorer($SearchQueryTransportHandler.messageReceived($SearchQueryTransportHandler.messageReceived(

it seems like one of filter clauses yields many hits and fully evaluate them too often, can you exclude it from the eagerly cached filters?

Is there any way to determine what filter that is?

it looks there is no Profile API at 1.7. You can manually check num hits under frequent clauses or experiment with "_cache": false

Got it, thanks.
Out of curiosity - if there's a filter that is constantly being performed, but matches a large range of documents, it's better not to cache it? Even though it's performed multiple times?

sometimes it makes a lot of sense