Typefully

Replica Placement and Selection in HDFS

Avatar

Share

 • 

3 years ago

 • 

View on X

Replica Placement and Replica Selection in HDFS 🧵
1️⃣ Replica Placement in HDFS HDFS clusters run on large no of computers spread across multiple racks. Network bandwidth between nodes in the same rack is greater than the bandwidth between the nodes in different racks. Hence, a replica placement policy is rack-aware in HDFS.
This is done to improve data reliability, availability and network bandwidth utilization. The Namenode determines the rack id each Datanode belongs to via the processed called "Hadoop Rack Awareness".
For default replication factor of 3, the replication policy is: If the writer is on the datanode, place the replica in that same machine. Otherwise, place it in any random datanode in the same rack as that of the writer.
Now place another one in a node on a different (remote) rack and the last replica on a different node in the same remote rack. This policy cuts the inter-rack write traffic which generally improves write performance without impacting data reliability and availability guarantees.
If the replication factor is greater than 3, the placement of the 4th and following replicas are determined randomly while keeping the number of replicas per rack below the upper limit (which is basically (replicas - 1) / racks + 2).
Because the NameNode does not allow DataNodes to have multiple replicas of the same block, maximum number of replicas created is the total number of DataNodes at that time. (This is the default policy and along with this, HDFS supports 4 more Block Placement Policies)
2️⃣ Replica Selection in HDFS To minimize global bandwidth consumption and read latency, HDFS tries to satisfy a read request from a replica that is closest to the reader. If a replica exists on the same rack as the reader node, then that is preferred to satisfy the read request.
If an HDFS cluster spans multiple data centres, then a replica that is resident in the local data centre is preferred over any remote replica. That's it for today! Thanks for reading 👋
Avatar

Aditya Gupta

@itsadityagupta

Data Engineer at @medianetads