Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

Elasticsearch Cluster Administration

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.

Elasticsearch Cluster Node RolesMaster Nodes3 dedicated, odd countData NodesStore shards, run queriesIngest NodesParse and enrich docsCoordinating LayerApps, Kibana, Logstash, Laravel clientsCluster State and Shard RoutingManaged by elected master, replicated to all nodes
Elasticsearch cluster administration starts with separating master, data, ingest, and coordinating responsibilities across dedicated nodes.

Sizing rules that survive real traffic

Use these baseline rules before you provision hardware or cloud instances.

  1. Run three dedicated master-eligible nodes on small instances. Never let heavy indexing share the master tier.
  2. Size data nodes for heap between 50% and 75% of RAM, capped near 31 GB to keep compressed OOPs efficient.
  3. Target shard sizes of 10–50 GB for search indices and 30–50 GB for time-series logs.
  4. Keep primary shard count stable at index creation. You cannot shrink primaries without reindexing.
  5. 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.

PatternBest forNode countTrade-off
Single nodeLocal dev only1No fault tolerance; yellow on replica settings
Small HA clusterCatalog search, SMB apps3 data + 3 masterHigher ops overhead than managed service
Hot-warm architectureLogs, metrics, SIEMHot SSD + warm HDD tiersRequires index lifecycle policies
Managed Elastic CloudTeams without dedicated opsVendor-managedCost 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.

Document Indexing and Shard FlowApplicationCoordinatingNodeIngestPrimaryShardRouting by _routing or _id hashOne primary per shard group, N replica copiesReplica Shard ANear-real-time syncReplica Shard BQuery load sharing
Indexing flow in Elasticsearch cluster administration: writes hit a primary shard first, then replicate before becoming searchable after refresh.

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.
Cluster Health StatesGREENAll shards allocatedNormal operationsYELLOWMissing replicasDegraded redundancyREDMissing primariesData loss riskAdmin Response MatrixGreen: tune slow queries and watch disk trendsYellow: restore nodes or adjust replica countRed: allocate stale primaries or restore snapshot
Elasticsearch cluster administration relies on interpreting green, yellow, and red health before users notice search failures.

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 write or search queues
  • 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.

Cluster Admin LifecycleDeployRoles and YAMLConfigureTemplates, ILMMonitorHealth, alertsBackupSnapshotsUpgradeRollingContinuous Loop: Review metrics weeklyRun restore drills each quarterDocument every allocation and reindex change
Production Elasticsearch cluster administration follows a repeating cycle of deploy, configure, monitor, backup, and rolling upgrade.

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.

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

Elasticsearch cluster administration is the ongoing work of keeping search, log analytics, and catalog filters online under load. It covers assigning dedicated master, data, and ingest node roles; sizing shards for your data volume; monitoring cluster health via the _cluster/health API; enforcing index lifecycle policies; and automating encrypted snapshots before you scale or upgrade nodes. A single-node install suits development only.

At minimum, run three dedicated master-eligible nodes plus separate data nodes. A small HA pattern uses three data nodes and three masters for catalog search or SMB apps. Log workloads often add hot-warm tiers. Single-node setups have no fault tolerance and typically show yellow health when replicas are configured.

For Nepali SaaS budgets, a three-data-node cluster on modest cloud instances often runs around Rs 15,000–25,000 per month (~USD 110–185). That horizontal layout usually beats one oversized node because you can restart nodes individually without full downtime. Managed Elastic Cloud costs more but removes dedicated ops overhead.

Start with workload type. Catalog search on WooCommerce or Magento 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, and each node should do one primary job well rather than sharing master duties with heavy indexing.

Dedicated master-eligible nodes hold cluster state and should never run heavy indexing. Data nodes store shards and execute queries. Ingest nodes run pipelines before documents reach indices. Coordinating-only nodes fan out search requests without holding data. Elasticsearch cluster administration starts by separating master, data, ingest, and coordinating responsibilities across dedicated nodes instead of stacking every role on one machine.

Target primary 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 because you cannot shrink primaries without reindexing. Plan one replica minimum for production, two if you need rack or zone fault tolerance. Oversharding hurts aggregations on layered navigation; undersharding limits write throughput during full reindex jobs.

Set persistent limits such as cluster.max_shards_per_node and disk watermarks at 85%, 90%, and 95% flood stage via PUT _cluster/settings. Configure elasticsearch.yml with cluster.name, node.roles, discovery.seed_hosts, and cluster.initial_master_nodes on each node. Enable xpack.security and transport TLS. Wrong discovery settings can split the cluster into two independent halves, corrupting write consistency.

The old default of five primary shards per index creates oversharded, slow clusters on modern hardware. Define composable index templates matching your naming pattern with appropriate number_of_shards, number_of_replicas, and refresh_interval. For Magento 2 catalog indices, align shard counts with category depth and SKU volume. Templates ensure every new index inherits sane settings automatically rather than silently using outdated defaults.

Green means all primary and replica shards are allocated, though you should still monitor latency. Yellow means primaries exist but some replicas are unassigned, common on single-node dev clusters or after losing a data node. Red means missing primary shards, causing partial or total query failure on affected indices. Treat red as incident severity one and investigate before users notice search failures.

Alert on JVM heap usage above 85% sustained for five minutes, thread pool rejections on write or search queues, pending cluster tasks above 100 for more than two minutes, disk usage crossing the high watermark on any data node, search latency p95 above your SLA (often 200–500 ms for catalog search), and snapshot failure on two consecutive scheduled runs. Pair these with application slow-query logs from Laravel Scout or custom clients.

ILM automates rollover, forcemerge, allocation to warm tiers, and deletion so log indices do not consume disk until someone manually deletes them at the worst moment. A typical policy rolls over hot indices at 40 GB or one day, moves them to warm after three days with zero replicas, and deletes after 30 days. Attach the policy through a composable template so new indices inherit rollover aliases automatically.

Never restart every data node at once because Elasticsearch needs primaries online to stay green. Use shard allocation filtering to exclude one node at a time with cluster.routing.allocation.exclude._name, wait until shards drain, stop the node, patch or upgrade, remove the exclusion, then repeat node by node. Verify cluster health between each step before proceeding to the next node.

Mapping changes require a new index. Run the Reindex API from the old index to the new one, then swap aliases with POST _aliases to remove the old index from the alias and add the new one. Schedule large reindex jobs off-peak and throttle with slices and requests_per_second to protect search latency for live users. Coordinate with catalog freeze windows on eCommerce rebuilds.

Enable TLS for transport and HTTP layers via xpack.security settings. Create roles scoped to index patterns rather than granting cluster-admin to every developer. Application service accounts should write only to indices they own. Separate Kibana admin users from ingest pipeline credentials and store secrets in your deployment vault, not Git. Never expose Elasticsearch directly to the internet without a gateway in front.

Register a snapshot repository pointing to S3-compatible storage, NFS, or a dedicated path, then schedule incremental snapshots with PUT _snapshot. Include specific index patterns, set ignore_unavailable true, and typically set include_global_state false for index-only backups. Test restores quarterly with POST _snapshot/.../_restore because a snapshot you have never restored is a guess, not a backup. Automate encrypted snapshots before scaling or upgrading nodes.

Share this article

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.

Quick Contact Options
Choose how you want to connect me: