HDFS Architecture and Operations
Apache Hadoop Distributed File System (HDFS) is the storage backbone of many big‑data solutions. It is designed to store massive data sets reliably and to provide high‑throughput access to…

During a read operation, how does the NameNode choose which DataNode to serve a block from?
Which daemon is responsible for periodically merging the edits log into the fsimage file?
If a DataNode fails while a client is reading a block, what does HDFS do?
What is the typical size of a data block in HDFS, and why is it larger than blocks in traditional file systems?
During file creation, which component handles the queuing and streaming of data packets to DataNodes?
Which of the following statements best describes the write semantics of HDFS?
What triggers the NameNode to select new DataNodes for block replication?
Which daemon receives regular heartbeats and block reports from all DataNodes?
How does HDFS achieve high availability on inexpensive hardware?
Understanding HDFS Architecture and Core Operations
Apache Hadoop Distributed File System (HDFS) is the storage backbone of many big‑data solutions. It is designed to store massive data sets reliably and to provide high‑throughput access to this data. This course breaks down the most important concepts that appear in typical HDFS quizzes, turning multiple‑choice questions into a clear, SEO‑friendly learning resource.
1. Default Replication Factor
One of the first settings you encounter when working with HDFS is the replication factor. By default, each data block is stored on three different DataNodes.
- Why three? Three replicas strike a balance between fault tolerance and storage overhead. With three copies, the system can tolerate the loss of up to two DataNodes without risking data loss.
- Administrators can change this value in
hdfs-site.xmlusing thedfs.replicationproperty, but the default of 3 is widely used in production clusters.
2. How the NameNode Chooses a DataNode for Reads
When a client requests a block, the NameNode does not simply pick any replica. It selects the DataNode that can deliver the data most efficiently, typically the one with the highest bandwidth to the client.
- The NameNode maintains network topology information (rack awareness) and bandwidth metrics for each DataNode.
- Choosing the highest‑bandwidth replica reduces latency and maximizes throughput, which is crucial for large‑scale analytics workloads.
3. Role of the SecondaryNameNode
The SecondaryNameNode is often misunderstood. Its primary responsibility is to periodically merge the edits log with the fsimage file, creating a new checkpoint.
- This process prevents the
editslog from growing indefinitely, which would otherwise slow down NameNode startup. - Although called “Secondary,” it does not act as a hot standby; it is a helper that reduces the recovery time after a NameNode failure.
4. Handling DataNode Failures During Reads
If a DataNode crashes while a client is reading a block, HDFS ensures continuity by redirecting the client to another replica of the same block.
- The client maintains a list of all replicas for each block. When a failure is detected, it automatically switches to the next available replica.
- This fail‑over mechanism is transparent to the user and is a key reason why HDFS can provide high availability for read‑intensive workloads.
5. Typical Block Size and Its Rationale
HDFS uses a default block size of 64 MiB (though many modern deployments configure 128 MiB or larger). This size is deliberately larger than the 4 KiB blocks found in traditional file systems.
- Large blocks reduce the amount of metadata the NameNode must manage, improving scalability.
- Fewer, larger blocks also lower the overhead of network round‑trips, which boosts throughput for sequential reads and writes.
- While 64 MiB is the historic default, administrators often increase the block size to match the characteristics of their hardware and network.
6. Data Streaming During File Creation
When a client creates a new file, the component that handles the queuing and streaming of data packets to the DataNodes is the DataStreamer.
- The DataStreamer runs in a separate thread, buffering data and sending it in packets to the chosen DataNodes.
- This design decouples the client’s write speed from the network latency of individual DataNodes, allowing smoother, high‑throughput ingestion.
7. Write Semantics of HDFS
HDFS follows a Write Once Read Many (WORM) model. Once a file is written, it cannot be modified in place; only appends are allowed.
- This restriction simplifies consistency management across a distributed cluster.
- While HDFS now supports appends and truncates, random writes or in‑place updates are still not part of its core semantics.
8. Triggering New Replication Decisions
The NameNode decides to replicate blocks when it receives a BlockReport indicating that a DataNode has failed or is missing a replica.
- Each DataNode periodically sends a BlockReport to the NameNode, summarizing the blocks it currently stores.
- If the NameNode detects that the replication factor for a block has fallen below the configured threshold (usually 3), it schedules new replicas on healthy DataNodes.
9. Putting It All Together: A Typical HDFS Workflow
Understanding the individual pieces becomes clearer when you follow a complete file‑write and read cycle:
- Client initiates file creation – the NameNode allocates a block ID and selects a set of DataNodes for the first replica.
- DataStreamer buffers data – it splits the incoming stream into packets and sends them to the chosen DataNodes.
- Replication occurs – as each block is written, the NameNode ensures that three replicas exist, choosing additional DataNodes based on bandwidth and rack awareness.
- Metadata checkpointing – the SecondaryNameNode periodically merges the edits log with the fsimage to keep the NameNode’s state compact.
- Client reads the file – the NameNode returns the list of replicas; the client picks the highest‑bandwidth DataNode.
- Failure handling – if a DataNode fails during the read, the client seamlessly switches to another replica.
10. Frequently Asked Questions (FAQ)
- Can I change the default replication factor? Yes, modify
dfs.replicationinhdfs-site.xmland restart the NameNode. - Is the SecondaryNameNode a backup for the NameNode? No, it only creates checkpoints; for high availability you need a standby NameNode.
- What happens if all replicas of a block disappear? The block is considered lost, and HDFS reports a corrupt file. Proper replication policies aim to avoid this scenario.
- Can I use a block size larger than 128 MiB? Absolutely – many clusters use 256 MiB or even 1 GiB blocks to further reduce metadata overhead.
11. Key Takeaways
Mastering HDFS fundamentals equips you to design resilient big‑data pipelines. Remember these core points:
- Default replication factor: 3.
- Read selection favors the DataNode with the highest bandwidth.
- The SecondaryNameNode merges edits into the
fsimagecheckpoint. - Read failures trigger automatic redirection to another replica.
- Typical block size: 64 MiB, chosen for efficiency.
- DataStreamer handles packet queuing during writes.
- HDFS follows a WORM write model.
- Replication decisions are driven by BlockReports indicating DataNode failures.
By internalizing these concepts, you’ll be prepared for both certification exams and real‑world Hadoop deployments.
