Node roles (master, data, ingest) in Elasticsearch - Time & Space Complexity
Start learning this pattern below
Jump into concepts and practice - no test required
When Elasticsearch runs, different nodes have different jobs like master, data, or ingest roles.
We want to understand how the work time changes as the cluster size or data grows.
Analyze the time complexity of this Elasticsearch node role setup:
{
"node": {
"master": true,
"data": true,
"ingest": false
}
}
This config sets a node to handle master and data tasks but not ingest tasks.
Look at what repeats when nodes handle their roles:
- Primary operation: Data nodes repeatedly store and search through shards of data.
- How many times: Once per shard per query or indexing operation, which depends on data size and cluster shards.
As data or cluster size grows, the work grows too:
| Input Size (n) | Approx. Operations |
|---|---|
| 10 shards | 10 shard operations per query |
| 100 shards | 100 shard operations per query |
| 1000 shards | 1000 shard operations per query |
Pattern observation: The number of shard operations grows roughly in direct proportion to the number of shards.
Time Complexity: O(n)
This means the work grows linearly with the number of shards or data pieces the node handles.
[X] Wrong: "Adding more master nodes will speed up data search operations."
[OK] Correct: Master nodes manage cluster state but do not handle data search directly; data nodes do the searching work.
Understanding how node roles affect work helps you explain system design and scaling clearly in interviews.
"What if we enabled ingest role on this node? How would that affect the time complexity of processing incoming data?"
Practice
What is the primary role of a master node in Elasticsearch?
Solution
Step 1: Understand node roles in Elasticsearch
The master node is responsible for managing the cluster state and coordinating nodes.Step 2: Differentiate master from other roles
Data nodes store data, and ingest nodes process documents. Master nodes handle cluster-wide tasks.Final Answer:
Manage cluster-wide settings and coordinate nodes -> Option AQuick Check:
Master node = cluster coordination [OK]
- Confusing master node with data node
- Thinking ingest node manages cluster
- Assuming master stores data
Which of the following is the correct way to assign a node as a data node in the elasticsearch.yml configuration file?
node.roles: [ ? ]
Solution
Step 1: Identify the role name for data nodes
Data nodes are assigned the role "data" in the node.roles setting.Step 2: Match the correct syntax
The correct syntax uses a list with the string "data" inside square brackets and quotes.Final Answer:
["data"] -> Option BQuick Check:
node.roles: ["data"] assigns data node role [OK]
- Using incorrect role names like "coordinating"
- Omitting quotes around role names
- Assigning master role instead of data
Given this node configuration snippet in elasticsearch.yml:
node.roles: ["master", "ingest"]
Which tasks will this node perform?
Solution
Step 1: Analyze the assigned roles
The node has roles "master" and "ingest", so it can do both tasks.Step 2: Understand what each role does
Master manages cluster state; ingest processes incoming documents before indexing.Final Answer:
Manage cluster state and process incoming documents -> Option CQuick Check:
Roles master + ingest = cluster + document processing [OK]
- Assuming node can only have one role
- Confusing ingest with data node role
- Ignoring master role effects
Look at this elasticsearch.yml snippet:
node.roles: master, data
What is the problem with this configuration?
Solution
Step 1: Check YAML syntax for node.roles
Roles must be defined as a list, e.g., ["master", "data"], not as a comma-separated string.Step 2: Validate role assignment rules
Assigning master and data roles together is allowed; roles are lowercase; node.roles is valid.Final Answer:
Roles must be listed as a YAML list with brackets and quotes -> Option AQuick Check:
YAML list syntax required for node.roles [OK]
- Writing roles as comma-separated string without brackets
- Using uppercase role names
- Thinking roles cannot combine
You want to create a node that only processes incoming documents but does not store data or manage cluster state. Which node.roles setting should you use?
Solution
Step 1: Identify the role for processing incoming documents
The ingest role processes incoming documents before indexing.Step 2: Exclude roles that store data or manage cluster
Data role stores data; master manages cluster state. We want neither.Final Answer:
["ingest"] -> Option DQuick Check:
Only ingest role processes documents without storing or managing [OK]
- Choosing data role which stores data
- Choosing master role which manages cluster
- Combining roles unnecessarily
