Elastic Search Adding nodes to cluster on the fly
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Elasticsearch is a highly scalable open-source full-text search and analytics engine which allows you to store, search, and analyze big volumes of data quickly and in near real time. It is generally used as the underlying engine/technology that powers applications with complex search features and requirements.
Adding nodes to an Elasticsearch cluster dynamically is a core feature that makes it extremely scalable. It allows for increasing the capacity of the cluster or replacing failed nodes without downtime. Here's how the process generally works and some key considerations.
Understanding Elasticsearch Clusters
An Elasticsearch cluster is a group of one or more nodes that together hold your entire data and provide federated indexing and search capabilities across all nodes. A node is a single server that is part of the cluster, capable of storing data, and participating in the cluster’s indexing and search capabilities.
Steps to Add a Node to an Elasticsearch Cluster
- Ensure Correct Configuration: Before you add a new node, make sure it has the correct settings in the
elasticsearch.ymlconfiguration file:cluster.namemust be set to the name of the cluster it should join.node.nameshould be unique within the cluster.- Network settings like
network.hostshould be configured to allow communications within the intended network.
- Start the Elasticsearch Service: Once the configuration is set, start Elasticsearch on the new node. If the settings are correct and network connectivity is established, the node will discover and join the cluster automatically, using the discovery mechanism specified in the configuration (e.g., Zen Discovery).
- Cluster Rebalancing: After the node joins the cluster, Elasticsearch begins rebalancing shards. Depending on the cluster settings, this may involve moving shards to the new node to evenly distribute the load and optimize resource usage across the cluster.
Dynamic Configuration Changes
Adding nodes can also trigger configuration changes. Some parameters in Elasticsearch can be updated on a live cluster using the Cluster API, such as:
- Updating index settings
- Tweaking shard allocation and recovery settings
- Adjusting node roles and responsibilities
Monitoring Node Addition
You can monitor the process of a new node joining a cluster using Elasticsearch’s monitoring APIs:
- Cluster Health API: Helps in checking the status of the cluster and ensure the new node is listed as part of the cluster.
- Cat Nodes API: Provides a detailed view of all nodes in the cluster and their current status.
Best Practices and Considerations
- Resource Allocation: Ensure that the new node has adequate resources (CPU, RAM, Disk) and is consistent with other nodes to prevent imbalances in the load distribution.
- Version Compatibility: The new node should ideally be running the same version of Elasticsearch as the rest of the cluster to prevent issues related to compatibility.
- Network Connectivity: Consider network latency and bandwidth, especially in cloud environments or when nodes are distributed geographically.
Key Summary Points
| Topic | Detail |
| Node Configuration | Set cluster.name and node.name, network settings |
| Starting the Node | Enable Elasticsearch service on the new node |
| Automatic Discovery | Node joins the cluster using discovery settings |
| Rebalancing and Resource Usage | Elastic rebalances shards across the new configuration |
| Monitoring | Use Cluster Health and Cat Nodes APIs |
| Best Practices | Consistent resource allocation, version, and networking |
Conclusion
Adding nodes on the fly to an Elasticsearch cluster is a powerful feature that enables scalability and flexibility. By understanding the core concepts and steps involved, and following best practices, you can ensure a smooth integration of new nodes into your Elasticsearch environment, enhancing both performance and reliability.
Related reading
- Elasticsearch 7.2.0 master not discovered or elected yet, an election requires at least X nodes
- Elasticsearch fails to start on AWS kubernetes cluster
- Elasticsearch helm chart gives AccessDenied exception
- Empty ADDRESS kubernetes ingress
- Elasticsearch and CAP Theorem
- ElasticSearch Couchbase Replication Issue
- Elastic Search how to move a primary shard?
- ElasticSearch constant_score query vs function_score query

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.