tezvyn:

HDFS: Store Big Data on Cheap, Unreliable Hardware

AI-drafted, machine-checkedSource: hadoop.apache.orgbeginner

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.

Read the original → hadoop.apache.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.