A Method to Improve the Performance for Storing Massive Small Files in Hadoop

Tong Zheng, Guisheng Fan, Weibin Guo2017

Abstract

As a new open source project, Hadoop provides a new way to store massive data. Because of high scalability, low cost, good flexibility, high speed and strong fault tolerance performance, it has been widely adopted by the internet companies. However, the performance of Hadoop will reduce significantly once it is used to handle massive small files. As a result, this paper proposes a new scheme to merge small files, which occupy much memory in NameNode, into large files and establish the mapping relationship between small files and large files, and then store the mapping information in HBase. In order to improve the reading performance, the scheme provides a prefetching mechanism by analyzing the access logs and putting the metadata frequently accessed merge files in the client’s memory. The experiment results show that this scheme can efficiently optimize small files storage in HDFS, thus reduce the overload of NameNode and improve the performance of file access.

Introduction

Hadoop’s Distributed File System (HDFS) was originally designed to handle massive files, typically in the gigabyte to terabyte range. However, modern data environments—characterized by social media logs, sensor data, and small images—frequently generate millions of files in the kilobyte range. This "small file problem" creates two critical bottlenecks:

  1. NameNode Memory Exhaustion: The NameNode stores all file metadata in RAM. Each file consumes approximately 150 bytes of memory. Storing millions of small files can quickly exhaust the NameNode’s capacity, limiting the entire cluster's scalability.
  2. RPC Overhead: Accessing a file requires a request to the NameNode. For small files, the network communication (RPC) and addressing time often exceed the actual data transfer time, significantly reducing throughput.

To address these issues, this paper proposes a method that merges small files into larger blocks, offloads metadata management to HBase, and implements a log-based prefetching mechanism.

Proposed Methodology

The proposed architecture bypasses HDFS limitations through a three-pronged approach: client-side merging, distributed metadata indexing, and proactive prefetching.

Client-Side Merging and Upload

Instead of uploading small files individually, the client buffers them into a temporary file in memory. This "merge file" is uploaded to HDFS only when it reaches the default block size (e.g., 64MB) or a specific time threshold ($T1$) is met. This ensures the NameNode manages one large file instead of hundreds of small ones, drastically reducing its memory footprint.

The proposed architecture for merging small files and managing metadata via HBase.

HBase Metadata Indexing

To maintain access to the original small files, the system creates a mapping index containing the small file name, the parent merge file name, size, and offset. This index is stored in HBase, a distributed database designed for high-concurrency lookups. By moving small-file metadata to HBase, the NameNode is freed to manage only large-scale data blocks.

Log-Based Prefetching

To optimize read performance, the system periodically analyzes HDFS access logs to identify "hot" files. It calculates access frequencies and proactively pushes the location metadata (host name and block number) of the most popular files into the client’s local memory.

The optimized file retrieval process using HBase and client-side memory caching.

When a client requests a "hot" file, it can bypass the NameNode entirely and retrieve data directly from the DataNode, significantly reducing latency.

Experimental Evaluation

The researchers evaluated the system on a four-node Hadoop cluster using a dataset of 100,000 small files (1 KB to 50 KB) in various formats (.txt, .doc, .jpg).

The experimental results demonstrated significant improvements over standard HDFS:

  • Memory Efficiency: For 100,000 files, NameNode memory usage dropped from 16MB to 2MB—an 88% reduction.
  • Write Performance: The total upload time for the dataset was reduced from 38.8 minutes to 23.8 minutes, representing a 39% speedup.
  • Read Performance: Reading the entire dataset took 59 seconds on vanilla HDFS but only 32 seconds with the proposed scheme, a 46% speedup.

The performance gap widened as the number of files increased, suggesting high scalability for larger clusters.

Conclusion

The proposed scheme effectively optimizes small file storage in HDFS by reducing NameNode overload and improving access speeds. Future work will focus on optimizing the merging logic based on file relevance (e.g., grouping files by user) and implementing dynamic tuning for the prefetching parameters ($N$ and $T1$) to better handle real-time cluster loads.

Summary updated

BibTeX
@misc{zheng2017method,
  author = {Tong Zheng and Guisheng Fan and Weibin Guo},
  title = {{A Method to Improve the Performance for Storing Massive Small Files in Hadoop}},
  year = {2017},
  doi = {10.22323/1.299.0022},
}
Figure