HDFS: Store Big Data on Cheap, Unreliable Hardware
HDFS stores huge files across many cheap computers by assuming they will fail. It achieves reliability by replicating data, not by using expensive hardware. Use it for batch processing, but avoid it for low-latency access or many small files.
Why it exists
To store petabyte-scale datasets for analysis, you cannot rely on a single, massive, expensive server. You must distribute the data across a cluster of cheaper machines. This introduces a new problem: with hundreds of commodity servers, hardware failure becomes a daily, expected event. HDFS was built to solve this by providing reliable storage on unreliable hardware.
The mental model
Think of HDFS not as a single hard drive, but as a smart librarian managing a fleet of unreliable assistants. The librarian (the NameNode) knows which book (file) is on which shelf (DataNode). Crucially, the librarian has made multiple photocopies (replicas) of every page (block) and stored them with different assistants, just in case one calls in sick.
How it works
HDFS uses a master/worker architecture. A central NameNode stores all the file system's metadata: the directory tree, file permissions, and which data blocks make up each file. A large number of DataNodes store the actual data blocks on their local disks. When a client writes a file, it's split into large blocks (e.g., 128MB or 256MB), and each block is replicated (usually 3 times) on different DataNodes across the cluster. To read a file, the client asks the NameNode for the locations of the blocks and then reads the block data directly from the DataNodes in parallel.
When to use it
Use HDFS for storing very large files (gigabytes to terabytes) that follow a write-once, read-many access pattern. It is the ideal storage layer for batch processing workloads like data warehousing and large-scale analytics where high aggregate throughput for sequential reads is more important than low latency for individual reads.
When not to use it
HDFS is the wrong tool for low-latency workloads, like a transactional database, because the overhead of coordinating with the NameNode is too high. It's also notoriously inefficient for storing a large number of small files. Each file, no matter how small, consumes memory in the NameNode, which can quickly become a bottleneck.
One canonical example
A web crawler ingests terabytes of raw HTML pages and stores them as large sequence files in HDFS. Later, a MapReduce job runs across the cluster to build a search index. The job reads the data in parallel from all DataNodes. If a disk or entire DataNode fails during the job, HDFS automatically serves the data from a replica on another node, allowing the job to complete without interruption.
Interview question
For which application type would HDFS be an unsuitable storage solution?
- a.A transactional database requiring millisecond response times for individual record lookupsCorrect
- b.Storing petabytes of historical sensor data for monthly analytical reports
- c.Distributing large files across a cluster of commodity servers to tolerate hardware failures
- d.Archiving terabytes of scientific simulation outputs for future research
Why? this is the answer
The card states HDFS is "the wrong tool for low-latency workloads, like a transactional database, because the overhead of coordinating with the NameNode is too high." The other options describe scenarios where HDFS is well-suited, such as batch processing of large files and leveraging unreliable hardware.
Just read this? Test yourself on what you have been reading.
Read the original → hadoop.apache.org
- #hdfs
- #big data
- #distributed systems
- #hadoop
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles