Improving Elasticsearch Read Performance

I've been thinking about Elasticsearch performance lately, and wanted to capture my thoughts here for longterm access.

There are a number of ways to optimize Elasticsearch for better search performance, and they tend to fall into a few specific categories:

  1. Query design
  2. Index Configuration
  3. Hardware and Cluster Design

Notice that hardware and Elasticsearch (ES) cluster settings tend to go last, because in my experience they have the smallest impact on performance. (Elasticsearch is fast by design and by default!)

Most of our "optimization" will focus on avoiding the more expensive features and simply letting ES be as fast as it already knows how to be.

Query Design

I think of these as the top 80% of offenders, though there are certainly other ES query features which can have a big impact on search performance. (One example is a percolate query.)

For a full reference, check out Limit expensive queries in the ES docs.

Index Configuration

Again, this is an intentionally short list of what I consider the "low hanging fruit" of optimizing ES read performance.

Hardware and Cluster Design

Conclusion

As I said earlier, Elasticsearch is fast by default. There are a number of features, however, which are computationally expensive and should be avoided for performance reasons. Besides that, as Elasticsearch clusters grow more time should be dedicated to tuning the shard count/replica count, heap, and other cluster management settings that can have an outsized effect on performance