
September 11, 2026
13 min read
By Kokil Thapa | Last reviewed: September 2026
Elasticsearch cluster administration is what keeps search, log analytics, and catalog filters online when traffic spikes or a node dies. A single-node install is fine for development. Production needs deliberate node roles, shard math, snapshot schedules, and runbooks your team can execute at 2 a.m. This guide walks through the decisions and commands I use when wiring Elasticsearch into Magento 2 search stacks, directory platforms, and the broader ELK observability pipeline.
How do you design an Elasticsearch cluster for production?
Start with workload type. Full-text product search on a WooCommerce or Magento store behaves differently from high-volume application logs. Catalog search needs predictable query latency and moderate ingest. Log pipelines need fast writes, time-based indices, and aggressive retention. Mixing both on one cluster without isolation is a common mistake.
Elasticsearch 8.x separates concerns through node roles. Each node should do one primary job well. Dedicated master-eligible nodes hold cluster state. Data nodes store shards and execute queries. Ingest nodes run pipelines before documents hit indices. Coordinating-only nodes fan out search requests without holding data.
Sizing rules that survive real traffic
Use these baseline rules before you provision hardware or cloud instances.
- Run three dedicated master-eligible nodes on small instances. Never let heavy indexing share the master tier.
- Size data nodes for heap between 50% and 75% of RAM, capped near 31 GB to keep compressed OOPs efficient.
- Target shard sizes of 10–50 GB for search indices and 30–50 GB for time-series logs.
- Keep primary shard count stable at index creation. You cannot shrink primaries without reindexing.
- Plan one replica minimum for production. Two replicas if you need rack or zone fault tolerance.
On a directory platform like Gulfbizlist, I treat Elasticsearch as a query accelerator backed by MySQL or PostgreSQL as the system of record. The relational database stays authoritative. Elasticsearch holds denormalised documents optimised for faceted filters and autocomplete. That split simplifies recovery when you must rebuild an index from SQL.
Hardware and cloud instance checklist
Data nodes need fast SSD storage. Network-attached spinning disks fail under merge pressure. For Nepali SaaS budgets around Rs 15,000–25,000 per month (~USD 110–185), a three-data-node cluster on modest cloud instances often beats one oversized node. Horizontal scale gives you rolling restarts without full downtime.
Compare deployment patterns before you commit budget.
| Pattern | Best for | Node count | Trade-off |
|---|---|---|---|
| Single node | Local dev only | 1 | No fault tolerance; yellow on replica settings |
| Small HA cluster | Catalog search, SMB apps | 3 data + 3 master | Higher ops overhead than managed service |
| Hot-warm architecture | Logs, metrics, SIEM | Hot SSD + warm HDD tiers | Requires index lifecycle policies |
| Managed Elastic Cloud | Teams without dedicated ops | Vendor-managed | Cost scales with data volume |
What are the essential Elasticsearch cluster settings you must configure?
Cluster settings fall into persistent, transient, and node-level YAML groups. Persistent settings survive restarts. Transient settings apply until the next full restart. Node YAML in elasticsearch.yml defines identity and paths.
elasticsearch.yml baseline for a data node
cluster.name: production-search
node.name: data-01
node.roles: [ data ]
network.host: 0.0.0.0
discovery.seed_hosts: ["master-01:9300","master-02:9300","master-03:9300"]
cluster.initial_master_nodes: ["master-01","master-02","master-03"]
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true Official reference: see the Elasticsearch settings documentation before changing defaults on a live cluster. Wrong discovery settings can split the cluster into two independent halves — a split-brain scenario that corrupts write consistency.
Cluster-wide settings via API
Apply persistent settings after the cluster forms. These two limits prevent runaway shard explosion during automated index creation.
PUT _cluster/settings
{
"persistent": {
"cluster.max_shards_per_node": 1000,
"cluster.routing.allocation.disk.watermark.low": "85%",
"cluster.routing.allocation.disk.watermark.high": "90%",
"cluster.routing.allocation.disk.watermark.flood_stage": "95%"
}
} Disk watermarks matter on shared EC2 volumes. I've seen a log cluster hit flood stage because nightly snapshots and merge segments filled the root volume. The cluster blocks writes cluster-wide until you free space or relocate shards. Monitor disk at the mount that holds path.data, not just aggregate server usage.
Index templates and default shard counts
Never rely on Elasticsearch defaults for production indices. Five primary shards per index was sensible years ago on tiny clusters. Today it creates oversharded, slow clusters. Define composable index templates that match your naming pattern.
PUT _index_template/app-search-template
{
"index_patterns": ["products-*"],
"template": {
"settings": {
"number_of_shards": 2,
"number_of_replicas": 1,
"refresh_interval": "5s"
}
}
} For Magento 2 catalog indices, align template shard counts with category depth and SKU volume. Oversharding hurts aggregations on layered navigation. Undersharding limits write throughput during full reindex jobs triggered by catalog updates.
How do you monitor Elasticsearch cluster health and performance?
Monitoring is the daily heartbeat of Elasticsearch cluster administration. You need cluster-level signals, node-level resource metrics, and index-level latency trends. Kibana Stack Monitoring covers the first two when X-Pack is enabled. Many teams also scrape Prometheus exporters and alert through Grafana.
Health API and what green, yellow, red mean
Run this check from any node or through your load balancer.
GET _cluster/health?pretty
GET _cat/nodes?v&h=name,node.role,heap.percent,cpu,load_1m,disk.used_percent
GET _cat/shards?v&s=store:desc Interpret status codes with urgency.
- Green: All primary and replica shards are allocated. Keep monitoring latency anyway.
- Yellow: Primaries exist but some replicas are unassigned. Common on single-node dev clusters or after losing a data node.
- Red: Missing primary shards. Queries against affected indices return partial or total failure. Treat as incident severity one.
Metrics worth alerting on today
Configure alerts before problems become outages. These thresholds work well as starting points on Linux hosts managed through Linux system administration practices.
- JVM heap usage above 85% sustained for five minutes
- Thread pool rejections on
writeorsearchqueues - Pending cluster tasks above 100 for more than two minutes
- Disk usage crossing high watermark on any data node
- Search latency p95 above your SLA (often 200–500 ms for catalog search)
- Snapshot failure on two consecutive scheduled runs
Pair infrastructure metrics with application signals. On Laravel apps using Scout or custom Elasticsearch clients, log slow queries with the index name and query body hash. That context beats staring at generic CPU graphs. Use the JSON formatter tool to inspect API payloads during incident triage.
How do you handle Elasticsearch index lifecycle and shard management?
Indices grow until they hurt. Index Lifecycle Management (ILM) automates rollover, forcemerge, allocation to warm tiers, and deletion. Without ILM, log clusters consume disk until someone manually deletes indices — usually at the worst moment.
ILM policy for time-series data
PUT _ilm/policy/logs-30d-retention
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": { "max_size": "40gb", "max_age": "1d" }
}
},
"warm": {
"min_age": "3d",
"actions": { "allocate": { "number_of_replicas": 0 } }
},
"delete": { "min_age": "30d", "actions": { "delete": {} } }
}
}
} Attach the policy through a composable template. New indices inherit rollover aliases automatically. This pattern mirrors how I manage Redis TTL caches alongside relational data on production Laravel apps — automate eviction so humans do not rely on calendar reminders.
Shard relocation and rolling restarts
Never restart every data node at once. Elasticsearch needs primaries online to stay green. Use shard allocation filtering when replacing hardware.
PUT _cluster/settings
{
"transient": {
"cluster.routing.allocation.exclude._name": "data-01"
}
} Wait until shards drain. Stop the node. Patch or upgrade. Remove the exclusion. Repeat node by node. The same rolling pattern applies to PostgreSQL administration failovers and MongoDB replica set maintenance — one node at a time, verify health between steps.
Reindex without downtime
Mapping changes require a new index. Use the Reindex API with alias swap.
POST _reindex
{ "source": { "index": "products-v1" }, "dest": { "index": "products-v2" } }
POST _aliases
{
"actions": [
{ "remove": { "index": "products-v1", "alias": "products" } },
{ "add": { "index": "products-v2", "alias": "products" } }
]
} Schedule large reindex jobs off-peak. Throttle with slices and requests_per_second to protect search latency for live users. On eCommerce rebuilds, coordinate with catalog freeze windows documented in your e-commerce development runbook.
How do you secure and back up an Elasticsearch cluster?
Security and backups are non-negotiable parts of Elasticsearch cluster administration. Elastic Stack 8.x enables security features by default on new installs. Legacy clusters may still run open endpoints on port 9200. Close that gap before the cluster touches production data.
Authentication, TLS, and role-based access
Enable TLS for transport and HTTP layers. Create roles scoped to index patterns rather than handing every developer cluster-admin privileges.
POST _security/role/app-search-reader
{
"indices": [
{
"names": ["products-*"],
"privileges": ["read", "view_index_metadata"]
}
]
} Application service accounts should write only to indices they own. Separate Kibana admin users from ingest pipeline credentials. Store secrets in your deployment vault, not in Git. The same discipline applies to API rate limiting on public-facing search endpoints — Elasticsearch should never be exposed directly to the internet without a gateway.
Snapshot and restore workflow
Cluster state alone is not enough. You need incremental snapshots to S3-compatible storage, NFS, or a dedicated repository path registered in Elasticsearch.
PUT _snapshot/nightly-repo/snap-2026-09-11
{
"indices": "products-*,logs-*",
"ignore_unavailable": true,
"include_global_state": false
}
POST _snapshot/nightly-repo/snap-2026-09-11/_restore
{
"indices": "products-*",
"rename_pattern": "(.+)",
"rename_replacement": "restored-$1"
} Official backup guidance lives in the Elasticsearch snapshot and restore guide. Test restores quarterly. A snapshot you have never restored is a guess, not a backup.
How do you troubleshoot common Elasticsearch cluster failures?
Most incidents fall into a short list. Build runbooks around them so on-call engineers do not grep forums under pressure.
Split-brain and master election issues
Split-brain happens when two master-eligible partitions both believe they lead. Prevent it with an odd number of dedicated masters and proper discovery.seed_hosts configuration. Never set minimum_master_nodes on modern versions — Elasticsearch 7+ uses cluster coordination that supersedes that legacy setting. If you inherit an old cluster during website migration, audit discovery settings before cutover.
Circuit breaker exceptions and heap pressure
circuit_breaking_exception means a query or aggregation requested too much memory. Fix the query first. Increase heap only after you confirm the query is sane. Common culprits include unbounded terms aggregations on high-cardinality fields and deep pagination with from/size instead of search_after.
Unassigned shards and allocation explain
GET _cluster/allocation/explain
{
"index": "products-v2",
"shard": 0,
"primary": true
} The explain output tells you whether disk watermarks, awareness attributes, or filter rules block allocation. Fix the root constraint. Only use cluster.routing.allocation.enable overrides during controlled maintenance windows.
Upgrade path and version compatibility
Upgrade one major version at a time. Read the Elastic release notes for breaking mapping and API changes. Roll through master-eligible nodes first, then data nodes, then coordinating tiers. Validate cross-cluster search and snapshot repositories in staging. Teams running multi-cluster GitOps patterns should pin infrastructure manifests to tested version pairs.
For Laravel-centric search without self-hosting Elasticsearch, evaluate managed alternatives or database-native full-text before you commit ops headcount. The AI-powered search for Laravel products article compares patterns when relevance tuning matters more than raw cluster control.
Key Takeaways
- Separate master, data, ingest, and coordinating node roles — never let masters run heavy indexing workloads.
- Set index templates and shard counts at creation time; fixing oversharding later requires reindexing.
- Alert on heap pressure, disk watermarks, thread pool rejections, and yellow cluster state lasting more than minutes.
- Automate ILM for time-series indices and verify snapshot restores on a schedule, not only snapshot creation.
- Use rolling restarts, allocation exclusions, and alias swaps for zero-downtime maintenance and mapping changes.
- Keep Elasticsearch behind authenticated TLS endpoints with least-privilege roles for each application service account.
People Also Ask
How many nodes do you need for a production Elasticsearch cluster?
A minimum production cluster uses three dedicated master-eligible nodes plus at least two data nodes for redundancy. Small workloads may combine roles on larger instances, but dedicated masters remain best practice once indexing exceeds casual traffic. Add ingest or coordinating nodes when CPU on data nodes stays pegged during bulk loads.
What is the recommended shard size for Elasticsearch indices?
Target 10–50 GB per shard for search workloads and up to 50 GB for logs after rollover. Smaller shards increase cluster metadata overhead. Shards far above 50 GB slow recovery and relocation. Calculate primary count as expected index size divided by target shard size, then add replicas for availability.
How do you reduce Elasticsearch heap memory usage?
Fix expensive queries before raising heap. Reduce aggregation cardinality, avoid deep offset pagination, and use doc_values where sorting and aggregations allow. Lower refresh frequency on bulk ingest indices. Keep JVM heap at or below roughly 31 GB per node. Move cold data to warm tiers through ILM instead of retaining everything on hot nodes.
Can you run Elasticsearch on the same server as MySQL or Laravel?
You can for development on a laptop or small VPS. Production should isolate Elasticsearch on dedicated hosts because merge threads, heap, and disk I/O compete directly with PHP-FPM and MySQL InnoDB buffers. On budget Nepali VPS plans around Rs 3,000/month (~USD 22), a separate search node still beats nightly outages on a shared box.
Build search infrastructure that stays up when traffic spikes
Elasticsearch cluster administration is not a one-time install task. It is ongoing capacity planning, health monitoring, snapshot verification, and disciplined upgrades. Whether you run catalog search for an international store or centralised logs for a legal-tech portal, the same rules apply: odd master count, right-sized shards, automated lifecycle, tested backups. Need help designing search for a Laravel app, Magento rebuild, or ELK deployment? Review the Quick And Easy Nepalese Grocery catalog work and related enterprise application development services, or reach out through contact us to plan stable Elasticsearch cluster administration for your next release.
Frequently Asked Questions
0 Comments
Leave a comment
Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

