HDFS Architecture

CHAPTER 5: HDFS Architecture

We have come to the half way of HDFS Tutorial and this HDFS Architecture is the 5th chapter of our HDFS Tutorial Series.This and the next to it will be an interesting chapter to read and most important as well. Concentrate on this and you will never face issue with understanding like how the system exactly works.

We have already talked about the Block, DataNode, and NameNode…right? Let’s see how these are being actually used and its operation.

As I have told you the file that we want to process gets divided into blocks and also I have told you that these DataNodes are commodity hardware then what in the case of failures?

Valid question…

Well, Hadoop is highly fault tolerant system. What we do here is, we replicate the blocks. Suppose you have 3 blocks then it will be replicated and stored so that in the case of any failure (though we have secondary NameNode), the data should not be lost.

By default, the replication factor in Hadoop is 3

That means all the blocks will be replicated 3 times. For example, if you 3 blocks then it will be replicated 3 times and so in total you have 9 blocks.

You can increase or decrease the replication factor and depend on the number of DataNode you have, select the replication factor. This can be done by changing in hdfs-site.XML file as shown below-

change replication factor through hdfs file

Here is a simple and self-explaining image of HDFS Architecture-

hdfs architecture

For the common case, when the replication factor is three, HDFS’s placement policy is to put one replica on one node in the local rack, another on a node in a different (remote) rack, and the last on a different node in the same remote rack. This policy cuts the inter-rack write traffic which generally improves write performance. The chance of rack failure is far less than that of a node failure; this policy does not impact data reliability and availability guarantees.
However, it does reduce the aggregate network bandwidth used when reading data since a block is placed in only two unique racks rather than three. With this policy, the replicas of a file do not evenly distribute across the racks. One-third of replicas are on one node, two-thirds of replicas are on one rack, and the other third are evenly distributed across the remaining racks. This policy improves write performance without compromising data reliability or read performance.

hdfs data nodes

So suppose we have 5 blocks, the below can be an ideal distribution-

Block Replication in Hadoop

Previous Chapter: Hadoop TerminologyCHAPTER 6: HDFS File Processing