Solving the cold start search problem in OpenSearch - OpenSearch

Solving the cold start search problem in OpenSearch

By [Aswath Srinivasan](/content/author/aswath-srinivasan/ "Posts by Aswath Srinivasan"/index.html), [Allan Pienaar](/content/author/allan-pienaar/ "Posts by Allan Pienaar"/index.html), [Fanit Kolchina](/content/author/fanit-kolchina/ "Posts by Fanit Kolchina"/index.html) January 7, 2025 June 18th, 2025

Upgrading to OpenSearch offers many advantages, but it can also introduce unexpected challenges. One such issue we’ve encountered while assisting with upgrades from older Elasticsearch versions is the “cold start search” problem. You might notice that the first search after a period of inactivity is unusually slow, even though subsequent searches perform as expected. This blog post will explore the root cause of this behavior and offer potential solutions tailored to your needs.

Understanding the cold start search problem

After upgrading from Elasticsearch 6.x to OpenSearch (or even to later Elasticsearch versions), you may see a pattern: the first search after some inactivity is slow, while subsequent searches run much faster. After another idle period, the slow search recurs. This issue is particularly noticeable in non-production environments, where search activity isn’t as constant as in live systems. The following image presents a typical search rate metric illustrating this behavior.

At first glance, this might look like a cache-warming issue. However, the pattern persists even for queries that don’t use caching. Both simple and complex queries are affected equally, and slow logs don’t identify these as slow queries. This means that caching or query complexity isn’t the cause of the problem.

Uncovering the root cause

Through detailed investigation using search slow logs and query profiling, we traced the root cause to two key settings in OpenSearch:

When upgrading from Elasticsearch 6.x to OpenSearch or Elasticsearch 7.x, this behavior can cause the first search after a long idle period to wait for the refresh to complete before executing. Older Elasticsearch versions didn’t exhibit this behavior because index.search.idle.after didn’t exist. The severity of the delay depends on how much data needs to be refreshed, which in turn depends on how much indexing occurred during the idle period.

Practical solutions for cold start searches

The best way to address this issue depends on your workload. Below are some common scenarios and recommended solutions:

Conclusion

Addressing the cold start search problem requires understanding your specific workload and priorities. Explicitly setting refresh_interval or adjusting index.search.idle.after can help, but each solution comes with trade-offs. For most production systems, this issue is less likely to occur because of continuous search activity.

Always test these configurations in your environment to find the right balance for your needs. For more tips on optimizing refresh intervals, check out our blog post on optimizing OpenSearch refresh intervals.