RousselTMLEARNING

Observability

Elasticsearch distributed architecture: node roles, shards, replicas and allocation

Understand how Elasticsearch works as a distributed system: node roles, master nodes and quorum, cluster state, primary shards and replicas, allocation and allocation awareness, failure detection and rebalancing.

1. Nodes and roles #

Who does what.

Roles #

Elasticsearch node roles
# elasticsearch.yml d'un nœud data hot
node.name: es-hot-01
node.roles: [ data_hot, data_content, ingest ]
node.attr.zone: eu-west-3a

The elected master node maintains the cluster state: list of nodes, mappings, location of each shard. A quorum of eligible nodes is required: with 3 eligible nodes, the cluster tolerates the loss of only one.

Common mistake: Two master-eligible nodes protect against nothing: losing one loses the quorum. Use 3 nodes (or 2 + a voting_only node).

2. Shards and replicas #

How data is distributed.

Principle #

Primary shards and replicas
  • An index is split into primary shards (fixed at creation); each one is a Lucene index.
  • Each primary has replicas (changeable on the fly): high availability and read capacity.
  • A replica is never placed on the same node as its primary.
  • Green status: everything is allocated; yellow: replicas are missing; red: primaries are missing.

3. Allocation and failures #

What happens when a node goes down.

Allocation #

  1. The node stops responding: the master removes it from the cluster.
  2. The replicas of its primaries are promoted to primaries: no data lost, the cluster turns yellow.
  3. After index.unassigned.node_left.delayed_timeout (1 minute by default), new replicas are rebuilt on the remaining nodes.
  4. When the node comes back, Elasticsearch rebalances the shards.
GET _cluster/health
GET _cat/shards?v&h=index,shard,prirep,state,node,unassigned.reason
GET _cluster/allocation/explain

# répartir les répliques entre zones de disponibilité
PUT _cluster/settings
{ "persistent": { "cluster.routing.allocation.awareness.attributes": "zone" } }
Good practice: With zone-based allocation awareness, a replica and its primary are always in two different zones: losing an entire zone loses no data.

Related articles

Transforms and enrich: summarising and enriching data in Elasticsearch

Build entity-centric indices with pivot and latest transforms, and enrich documents at ingest time with enric…

OpenTelemetry and Elasticsearch: compatibility and architecture

Send OpenTelemetry to Elasticsearch: Collector and elasticsearch exporter, managed OTLP endpoint, APM Server,…

Ingesting OpenTelemetry logs into Elasticsearch

Collect and structure logs with the OpenTelemetry Collector (filelog receiver, operators, transform processor…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!