Hadoop Distributed File System (HDFS) Explained: Blocks, Replication and a 300 MiB Worked Example
Follow one 300 MiB HDFS file from NameNode metadata to DataNode blocks, nine replicas and failure recovery, with exam traps explained along the way.
KnowledgeGate Team
Exam prep & CS education

HDFS is often reduced to "NameNode plus DataNodes", but exam questions mix four separate ideas: who stores metadata, how a file becomes blocks, where replicas go, and what survives a node failure. /exam/results.csv is a 300 MiB file with a 128 MiB block size and replication factor 3. These numbers are teaching assumptions because HDFS settings are configurable. Follow this one path through the calculation, placement and recovery trace, then use CS Fundamentals for Exams & Placements to place HDFS within the wider systems syllabus.
What HDFS is designed to do, and what it is not designed to do
The Apache HDFS Architecture guide describes reliable storage on commodity hardware, automatic recovery, streaming access to large data sets and high throughput. Its model is write-once-read-many, with append and truncate support.
HDFS suits large sequential reads and batch processing, not low-latency interactive access or huge populations of tiny files. Each file adds metadata that the NameNode must hold even when its payload is small. HDFS sits under Big Data Systems in DBMS, so the DBMS subject map is a useful next step. Unlike a local file system on one machine, HDFS presents a namespace across cluster storage. It is not always faster than local storage.
HDFS architecture: client, NameNode, DataNodes and blocks
The four roles become clear when metadata and payload are kept separate.
Component | Keeps or does | Does not do | Example |
|---|---|---|---|
Client | Asks for metadata and streams data | Choose placement | Reads and writes |
NameNode | Owns | Store file payload | Keeps permissions, factor and locations |
DataNodes | Store and serve block replicas | Own the namespace | Hold |
Blocks | Are fixed-size logical chunks, except a shorter final block | Manage metadata | Form |
Apache assigns namespace and block-location decisions to the NameNode. DataNodes serve client I/O, creating, deleting or replicating blocks when instructed. User data bypasses the NameNode. File details and block locations are metadata; payloads live on DataNodes.
Worked HDFS example: split 300 MiB and calculate replicated storage
Assume /exam/results.csv has logical size 300 MiB, block size 128 MiB and replication factor 3. Ignore checksums, metadata files, file-system overhead, compression and erasure coding. The last block consumes only its actual payload bytes.
Number of blocks =
ceil(300 / 128) = ceil(2.34375) = 3.B0 = 128 MiBandB1 = 128 MiB, soB2 = 300 - 128 - 128 = 44 MiB.Logical size remains
128 + 128 + 44 = 300 MiB.Total replicas =
3 blocks x 3 replicas = 9 block replicas.Replicated payload =
(128 + 128 + 44) x 3 = 300 x 3 = 900 MiB.Redundancy beyond the logical file =
900 - 300 = 600 MiB.
In the hypothetical placement, Rack A has DN1: B0, B1, B2; DN2 and DN3 have none from this file. Rack B has DN4: B0, B2, DN5: B0, B1 and DN6: B1, B2. Check: DN1 300 + DN4 172 + DN5 256 + DN6 172 = 900 MiB.
The trap 3 x 128 x 3 = 1,152 MiB treats the final block as full. Here, final B2 contains only 44 MiB.

HDFS write pipeline and read path using the same blocks
To write B0, the client asks the NameNode to create /exam/results.csv. The NameNode chooses and returns DN1, DN4, DN5. The client sends packets to DN1, which stores and forwards them to DN4. DN4 stores and forwards them to DN5. Acknowledgements return DN5 -> DN4 -> DN1 -> client. Apache calls this replication pipelining. The client does not send three independent full writes, and the 128 MiB payload never passes through the NameNode. Acknowledgements confirm each packet back through the chain before the client progresses.
To read B2, the client asks the NameNode for locations and receives DN1, DN4, DN6. It selects an appropriate replica, considering proximity, and checks the returned data with HDFS checksums. If that replica is corrupt or unavailable, it can try another. Metadata lookup goes to the NameNode, but block I/O goes directly between the client and a DataNode.
DataNode failure, heartbeat detection and re-replication
Now fail DN5. Its B0 and B1 replicas leave service, so each falls from 3 available replicas to 2. B2 remains at 3. The file stays readable because every block still has live replicas. This is under-replication, not the loss of either logical block.
DataNodes send heartbeats and block reports. Apache explains that missing heartbeats let the NameNode identify an unavailable DataNode, track under-replicated blocks and schedule new replicas. There is no universal detection time to memorise because timeout and staleness behaviour are configurable.
For this teaching repair, copy B0 from DN4 to DN6 and B1 from DN6 to DN4. The repaired maps are B0 -> DN1, DN4, DN6, B1 -> DN1, DN6, DN4 and B2 -> DN1, DN4, DN6. Real targets follow HDFS placement and storage policies, not these illustrative labels.

Metadata persistence, checkpoints and NameNode high availability
Apache's metadata model uses FsImage as a persisted image of the namespace and EditLog to record namespace changes. A checkpoint applies accumulated edits to an image and produces an updated, consistent view. FsImage does not contain the 300 MiB payload.
This is why checkpointing by a Secondary NameNode is not the same as a hot-standby failover service. In an HA deployment using the Quorum Journal Manager, Active and Standby NameNodes share edits through JournalNodes. Only the Active handles client operations at any one time; Standby nodes maintain state for failover.
Keep three failures distinct. A DataNode failure is absorbed by the surviving replicas and repaired by re-replication. A NameNode failure without HA stops the metadata service, so the namespace becomes unreachable even though every block on every DataNode is intact. A NameNode failure with HA is taken over by the Standby, which restores the metadata service but does nothing about missing block replicas.
How exams test HDFS: five patterns and their traps
Question cue | Correct result for this example | Common wrong turn |
|---|---|---|
Block count |
| Use floor division |
Last block |
| Assume |
Replica count |
| Answer 3 |
Replicated payload |
| Calculate |
Failed DN5 | B0 and B1 fall to | Declare the file unavailable |
Namespace and block mapping point to the NameNode; payload and client I/O point to DataNodes. B0 follows client -> DN1 -> DN4 -> DN5, never client -> NameNode -> every DataNode.
"Secondary NameNode is a hot backup" is false in the checkpointing sense. "Replication factor 3 survives any three node failures" is false because survival depends on replica placement.
These cues stick faster on real questions than on definitions. Use DBMS MCQs for practice and GATE Guidance by Sanchit Sir for the exam sequence.
HDFS short version and the next step
NameNode means metadata and placement decisions.
DataNode means block payload and client I/O.
Replication means multiple copies of every block.
Heartbeat loss means the NameNode may schedule re-replication.
For a five-minute revision, recompute 300 -> 128 + 128 + 44, then 3 blocks -> 9 replicas -> 900 MiB. Redraw the DN5 failure without looking. Then explain aloud why the shorter final block changes storage. Use Zero to Hero, Complete CS Course for a broader CS fundamentals path, or the GATE guidance course above when your immediate goal is a full GATE CS sequence.
Keep learning
Reliability in Distributed File Systems: Replication, Quorums and Worked Failure Examples
See how a distributed file system turns one pathname into metadata and replica requests, then calculate read-one and majority-quorum availability step by step.
Distributed Systems Basics Explained: Clocks, Quorums and Worked Examples
Learn how messages, replicas, quorums and logical clocks make distributed systems predictable. Two worked examples show how to calculate overlap and event order.
Distributed Systems in Operating Systems: Worked Examples for GATE and Interviews
Learn how distributed operating systems reason about messages, causality, coordination, consistency, replication, and partial failure. Follow exact RPC, clock, quorum, and file-replication examples built for exam and interview practice.
Distributed Systems in Operating Systems: Clocks, Consistency and Worked Examples
Build a connected understanding of distributed systems through exact examples of duplicate RPC calls, logical clocks, leader election, replica quorums and block recovery.





