24/7 Magento, server & cloud support · USA · UK · Europe · Middle East · Asia hello@scripulse.com
Magento9 min read

Magento OpenSearch Performance Optimization: A Practical Guide

Tune OpenSearch for Magento 2: JVM heap, shards, searchable attributes, reindexing, too_many_clauses errors and disk watermarks.

Magento 2.4 relies on a search engine — OpenSearch, or Elasticsearch on older 2.4 releases — for catalog search and layered navigation. When it is undersized or poorly configured, category pages slow down, reindexing drags on and search can fail completely.

Size the JVM heap correctly

Set the heap to no more than about half of the node’s memory, leaving the rest for the operating system’s file cache, and keep it below roughly 31 GB so the JVM can use compressed object pointers. Set minimum and maximum to the same value:

# jvm.options
-Xms4g
-Xmx4g

Monitor heap usage and garbage collection with GET _nodes/stats/jvm.

Use sensible shard and replica settings

On a single-node cluster, replicas cannot be allocated and leave the cluster yellow. Either set replicas to zero for single-node setups or run a proper multi-node cluster for high availability. Avoid many tiny shards; check with GET _cat/indices?v.

Review searchable attributes

Every attribute marked “Use in Search”, “Visible in Advanced Search”, “Use in Layered Navigation” or used for sorting adds to the index and to query complexity. Large catalogs often carry many attributes that nobody searches. Reviewing them reduces index size, speeds up queries and shortens reindex time.

Fix “too_many_clauses” errors

Stores with many searchable attributes or long search terms can generate queries that exceed the maximum boolean clause limit, producing too_many_clauses errors and failed searches. Reduce searchable attributes first; raising the limit treats the symptom and increases resource use.

Reindex strategy

  • Use “Update by Schedule” for large catalogs so changes are indexed incrementally by cron.
  • Schedule full reindexes away from peak hours.
  • Make sure cron runs reliably; a stalled cron leaves the search index out of date.

Watch the disk watermarks

OpenSearch stops allocating shards when disk usage crosses the low and high watermarks (85% and 90% by default) and marks indices read-only at the flood stage (95% by default). A read-only index silently stops catalog updates. Alert well before these thresholds.

Use slow logs

PUT /your_index/_settings
{ "index.search.slowlog.threshold.query.warn": "2s",
  "index.search.slowlog.threshold.query.info": "500ms" }

Slow logs reveal which queries, often from layered navigation with many filters, need attention.

Secure the cluster

Never expose OpenSearch to the internet. Bind it to private interfaces, restrict access by firewall, and enable authentication where supported. Exposed search clusters are a common source of data leaks.

Slow Magento search or category pages?

We tune OpenSearch, MySQL, caching and code together. Request a performance audit →

S
Scripulse Engineering Team
Written and reviewed by our Magento, Linux, SRE, cloud and security engineers. About our team.
Let’s talk

Need a reliable engineering partner for your platform?

Tell us what you need. A senior engineer will reply within one business day with a clear next step.

Book a free audit →