• No results found

Dealing with Small Files Problem in Hadoop Distributed File System

N/A
N/A
Protected

Academic year: 2021

Share "Dealing with Small Files Problem in Hadoop Distributed File System"

Copied!
12
0
0

Loading.... (view fulltext now)

Full text

(1)

Procedia Computer Science 79 ( 2016 ) 1001 – 1012

1877-0509 © 2016 Published by Elsevier B.V. This is an open access article under the CC BY-NC-ND license (http://creativecommons.org/licenses/by-nc-nd/4.0/).

Peer-review under responsibility of the Organizing Committee of ICCCV 2016 doi: 10.1016/j.procs.2016.03.127

ScienceDirect

7th International Conference on Communication, Computing and Virtualization 2016

Dealing with Small Files Problem in Hadoop Distributed File

System

Sachin Bende

a

, Rajashree Shedge

b,

*

aRamrao Adik Institute of Technology, Nerul, Navi Mumbai – 400 706, Maharashtra, India bRamrao Adik Institute of Technology, Nerul, Navi Mumbai – 400 706, Maharashtra, India

Abstract

The usage of Hadoop has been increasing greatly in recent years. Hadoop adoption is widespread. Some notable big users such as Yahoo, Facebook, Netflix, and Amazon use Hadoop mainly for unstructured data analysis as Hadoop framework works very well with structured and unstructured data. Hadoop distributed file system (HDFS) is meant for storing large files but when large number of small files need to be stored, HDFS has to face few problems as all the files in HDFS are managed by a single server. Various methods have been proposed to deal with small files problem in HDFS. This paper gives comparative analysis of methods which deals with small files problem in HDFS.

© 2016 The Authors. Published by Elsevier B.V.

Peer-review under responsibility of the Organizing Committee of ICCCV 2016. Keywords: HDFS; Small files problem; MapReduce; Hadoop

1.Introduction

HDFS gives the programmer unlimited storage and is the only reason behind turning to Hadoop. But when it comes to storing lot of small files there is a big problem. HDFS is capable of handling large files which are GB or TB in size. Hadoop works better with a small number of large files and not with large number of small files. Large number of small files take up lots of memory on the Namenode. Each small file generates a map task and hence

* Corresponding author. Tel.:+91 80 97 139596; fax: +91 22 27709573. E-mail address: [email protected]

© 2016 Published by Elsevier B.V. This is an open access article under the CC BY-NC-ND license (http://creativecommons.org/licenses/by-nc-nd/4.0/).

(2)

there are too many such map task with insufficient input. Storing and transforming small size file in HDFS creates an overhead to map reduce program which greatly affects the performance of Namenode.

Large amount of high speed data presents new kind of challenges that traditional database system has limits to resolve. Every organization had expertise to manage structured data but the world had already changed to unstructured data. All of these needed to now bring to a single platform and build a uniform system and Big Data fulfill this need.

Big Data does not mean lots of data. It is actually a concept providing an opportunity to find new insight into existing data and guidelines to capture and analysis future data1.

Apache Hadoop is freely available java based software framework. It offers a powerful distributed platform to store and manage Big Data. It runs applications on large clusters of commodity hardware. It processes thousands of terabytes of data on thousands of the nodes. The major advantage of Hadoop framework is that it provides reliability and high availability.

Fig 1. The Apache Hadoop Framework

The Apache Hadoop framework shown in Fig.1 is composed of the following modules2:

x Hadoop Common

x Hadoop Distributed File System (HDFS)

x Hadoop MapReduce

x Hadoop Yarn

Beyond HDFS, YARN and MapReduce, also there are some related projects which equally contribute to Apache Hadoop “platform” which includes HBase, Zookeeper, Hive, Apache pig, Chukwa, Avro3.

In charge of memory usage, if vast number of small files are reserved in HDFS it create an overhead. In the Namenode memory every file, directory and block in HDFS acts as an entity. Default size of HDFS block is 64 megabytes. Files whose size is smaller than the default block size in HDFS are termed as small files.

HDFS does not work well with lots of small files due to following reasons:

x Every block is capable of handling a single file, results into a lot of small blocks smaller than the configured block size. To read this much of blocks one after another is very time consuming.

x Namenode keeps a record of each file and block and preserve this data into memory. Large number of files requires more memory space4.

Rest of the paper is classified as follows. Section II presents the literature review. Section III presents existing techniques to deal with small files problem in HDFS. Section IV gives the detailed comparison and analysis of

(3)

different techniques described in Section III by considering common parameters. Section V concludes with the references at the end.

2.Literature Review

The purpose of this literature survey is to identify what research has already been done to deal with small files in Hadoop distributed file system.

2.1.HDFS and MapReduce

There are two primary components at the core of Apache Hadoop: the HDFS and the MapReduce parallel processing framework5.

Fig 2. High Level Architecture of Hadoop

x HDFS is the ‘file system’ or ‘storage layer’ of Hadoop, which is designed for storing very big files with streaming data access patterns, running on clusters.

x MapReduce is a programming model and an associated implementation for processing and generating

large data sets6, 7.

Fig 3. HDFS Architecture.

2.2.Related Work

Vaibhav Gopal Korat, Kumar Swamy Pamu8 proposed the Hadoop archiving technique which will reduce the storage overhead of data on Namenode and also helps in increasing the performance by reducing the map operations in the mapreduce program.

(4)

Jilan Chen, Dan Wang, Lihua Fu, Wenbing Zhao9 proposed the idea to merge small files in the same directory into large one and accordingly build index for each small file to enhance storage efficiency of small files and reduce burden on Namenode caused by metadata. Also, Cache policy that improves the reading efficiency of small files on HDFS is presented.

Kashmira P. Jayakar, Y.B.Gurav10 has proposed a solution call Extended Hadoop Distributed File System (EHDFS). In this approach, a set of correlated files is combined, as identified by the client, into a single large file to reduce the file count. An indexing mechanism has been built to access the individual files from the corresponding combined file. Further, index prefetching is also provided to improve I/O performance and minimize the load on Namenode.

Chatuporn Vorapongkitipun, Natawut Nupairoj11 proposed a method called New Hadoop Archive (NHAR) based on Hadoop Archive (HAR). This method maximizes the memory usage for metadata and boost the ability of accessing small files in HDFS. As HAR would not allow to add files into an existing archive files. NHAR enhance HAR potential by letting additional files to be inserted.

Priyanka Phakade, Dr. Suhas Raut12 have designed improved model for processing small files. Here system performance is improved by modifying InputFormat class. InputFormat will be modified in such a way that multiple files are combined into a single split. So, the map task will get more input to process, unlike existing system. As a result, the time required to process large number of small files will be minimized. In addition, multiple reducers will be used for taking advantage of parallelism.

3.Different Techniques to deal with small files problem 3.1.Hadoop Archive

The very first technique is Hadoop Archive (HAR). Hadoop archive as the name is based on archiving technique which packs number of small files into HDFS blocks more efficiently. Files in a HAR can be accessed directly without expanding it, as this access is done in main memory.

Fig 4. Data Model for Archiving Small Files8

Creating HAR will reduce the storage overhead of data on Namenode and reduced map operations in mapreduce program increases performance.

Creating HAR file: A HAR file is created using the Hadoop archive command

hadoop archive -archiveName name -p <parent> <src>* <dest> which runs a map reduce job to pack the files being archived into a small number of HDFS files. Example:

(5)

hadoop archive -archiveName firsttry.har -p /user/hadoop dir1 dir2 /user/Sachin

HAR File layout overhead: File access requires two index-file read operations as well as one data-file read operations there is a slight overhead in referencing files. To access the required file, the request goes to the index of metadata that the archive consists of through the metadata of the archive8.

Reading files in HAR is less efficient and much slower than reading files in HDFS. Map process fail to operate over all the files in the HAR co-resident on a HDFS block.

Upgrading HAR requires the changes of HDFS architecture, which may become difficult. 3.2.Improved HDFS

The improved HDFS structure comprised of two parts:

Client component which integrate small files into a big file and data node component which satisfies the cache resource management9.

Fig 5. Improved HDFS Framework9

Improved HDFS model is index-based. Based on file dependency, files belonging to the same directory are integrated into a big file and accordingly build index for each small file to reduce waste caused by them which reduces the burden of Namenode.

Cache policy is to increase the reading efficiency of small files. The cache manager is positioned at Datanode, when reading small file data each time, the data in the Cache are firstly searched. If this resource is not in the cache, resource can be found from the disk of Datanode.

The Design of file integration: Each big file has an index file which contains the offset and length of each original small file.

The process of file integration:

x Sort small files under the directory based on their, and write small files into big file one by one. x Determine the total sum of the small files.

x Determine the size of the big file and compare results with the HDFS block default size.

The index file is created considering offset and length of every small file. To store big files in one block, the entire size of big file should be less than the size of the block.

If the entire size of the file is more than the block size multiple blocks are used to store big files separately9. Based on the above paradigm, the offset and sequence of each file in a big file is identified, and accordingly index file is built, so file integration process ends.

(6)

3.3.Extended HDFS

This method extends HDFS and has been named as Extended HDFS (EHDFS). EHDFS is index-based, when the number of small files is very large in the index file, updating index may become more difficult. To enrich the read performance of HDFS, prefetching approach is used.

EHDFS provides an improved indexing mechanism and prefetching of index information. EHDFS has four techniques that play an important role in improving the efficiency with which HDFS handles small files. They are file merging, file mapping, prefetching and file extraction.

The overall system architecture depicting the placement of the modules that handle these operations is shown in Fig. 6

Fig 6. Extended HDFS Architecture10

File Merging: During file merging Namenode maintains metadata only for the combined file and not for all the small files present in it. In addition to file data, an index table is also placed at the beginning of each block. This table contains an entry for each small file that is a part of this block. Every table entry is an (offset, length) pair. Block structure after merging is shown in fig. 7

The extended blocks represent a part of the combined file. Along with other normal file blocks the extended blocks are stored as any other block in HDFS Datanode.

The storage of blocks in Datanode is depicted in Fig. 8

(7)

Fig 8. Structure of an extended block10

File Mapping: Carried out by the Namenode. File mapping is the process of mapping the small file name to the block of the combined file that contains this file. A request containing small file and combined file name is sent to the Namenode, for obtaining the location of the desired small file.

Namenode maintains a data structure called ConstituentFileMap, for each combined file10. Small file name and the logical block number of the combined file that holds this small file are mapped. Namenode also provides an “index entry number” which specifies entry in the index table stored at the beginning of the block.

Fig. 9 shows the ConstituentFileMap data structure for a combined file named temp.

Fig 9. Constituent File Map structure10

Prefetching: File Merging does not rise the performance of read operations. It only reduces the metadata footprint in the Namenode. Reading small files, places a considerable load on the Namenode, making it a bottleneck in the system. By providing a framework for prefetching file metadata EHDFS overcomes this bottleneck.

During prefetching whenever the client tries to read a small file, present as a part of the combined file. Metadata for other small files in the same block, as that of the requested file, is prefetched from the Namenode.

File Extraction: Carried out by the Datanode. File extraction involves the process of extracting the desired file contents from a block.

While reading a file, client specifies both the name of the small file and the name of the combined file. This information is used to obtain,

x The block holding the file. x The Datanode holding the block.

(8)

3.4.New HAR

The basic ideas of NHAR consist of two aspects:

x Merging small files into larger ones to reduce file number and optimize access performance. x Extending the functionality of file management within HAR to be similar to a typical file system11. NHAR re-construct the indexing structure to improve the metadata mainframe of HDFS and file accessing performance without altering the HDFS architecture. New design enables NHAR to allow additional files to be added to the existing archive which is HARs well-known limitation.

While reading file from HAR, indexes need to be accessed twice which creates inessential overheads. In order to improve the access performance NHAR model use single-level index. NHAR uses index information to create a hash table instead of master-index approach. These information is splited over multiple index files, as shown in fig. 10

Fig 10. NHAR file structure11

Locating the index file containing the metadata is depend upon the number of index files present. To derive hash code, file names are used which is then mods with number of index files11.

The actual file will be stored in part file, similar to HAR. Fig. 11 presents the hashing mechanism of NHAR.

Fig 11. New archive technique11

To add an additional file to the HAR file, a new HAR file must be created, which is very inefficient. In terms of NHAR there is no need to reconstruct a new NHAR file. It allows to add additional files to the existing NHAR file. The inserting process involves three steps: Archiving the new files, merging index files and moving the new part file. For example, inserting file-7 and file-8 into bar.har.

(9)

Example:

Fig 12. Inserting files into NHAR11

The inserting process is executed as following11:

x Archive the files to tmp.har using archiving program.

x In order to prevent file duplication check the part file (Part-0, Part-1,…) in bar.har that already exists or not.

x Merge index files in tmp.har with existing index files in bar.har. x Move the part file in tmp.har to bar.har.

x Delete tmp.har

3.5.CombineFileInputFormat

Existing HDFS system uses multiple mappers & Single reducer. InputFormat is responsible for splitting the input files. MapReduce framework spawns one map task for each InputSplit generated by the InputFormat for the job. This method improves system performance by modifying InputFormat class. InputFormat will be modified in such a way that multiple files are combined into a single split. Each map task will get more input to process, unlike existing system. Time required to process large number of small files will be minimized. Multiple reducers are used to achieve parallelism12.

Fig 13. Workflow of CombinedFileInputFormat12

Namenode permits HDFS client to store small files in HDFS. When small files are submitted, Namenode combines files into single split. This is given as input to map task. Intermediate o/p is produce by map task. This o/p is given to multiple reducers as an input. Reducer gives sorted merge output. As the number of map tasks has

(10)

reduced, the processing time gets decreases. Above average performance improvement is expected with CombineFileInputFormat.

4.Comparative Study and Analysis

Table I shows the comparative analysis of five methods to deal with small files problem in HDFS. The very first method HAR provides high scalability by reducing namespace usage and reading efficiency of files. There is a drastic change in reduce operation before and after archiving files which shows that there is increase in performance time.

With Improved HDFS writing and accessing performance of small files greatly increases and the average memory usage ratio of improved HDFS is decreases as compared to original HDFS. Due to cache manager this method provides high scalability. If file is not in cache it includes overhead of searching resource in cache as well as at Datanode.

Table 1. Comparison & Analysis Parameters Used Paper Name Reduction of data at Namenode in HDFS using Harballing Technique8 An improved small file processing method for HDFS9 Efficient Way for Handling Small Files using Extended HDFS10 Improving Performance of small-file Accessing in Hadoop11 An Innovative Strategy for Improved Processing of Small Files in Hadoop12 Method Archive-Based Index-Based Index-Based Archive-Based InputFormat-Based Positioning Namenode Datanode Namenode Namenode Namenode Memory Usage Very Low Low Moderate Slightly

High

High

Reading Efficiency / Addressing Time

Moderate Moderate High High Very High

Performance Moderate Moderate High High Very High

Scalability High High High High Very High

Overhead Slight High Low Low Slight

EHDFS allows for greater utilization of HDFS resources by providing more efficient metadata management for small files. The EHDFS only maintains the file metadata for each small file and not the block metadata. The block metadata is maintained by the Namenode for the single combined file alone and not for every single small file. This accounts for the reduced memory usage in the EHDFS. EHDFS can improves the efficiency of accessing small files and reduces the metadata footprint in Namenode’s main memory. System performance lost is in proportion to number of node failed in HDFS, to avoid this problem replication is implemented in Extended HDFS, so ultimately it will reduce system performance lost. This method provides high scalability as mapping technique maintain file to logical block number mapping as a part of the file name and low overhead making use of index entry number. NHAR consumes more memory slightly. This is due to the NHAR index file strategy, which has 4 index files design instead of the original 2 index files resulting into additional overhead to Namenode. HAR also enables to allow additional files to be added to the existing archive, which gives high scalability.

In last method, the InputFormat will be modified in such a way that many files will be combined into single split so that each mapper will have more to process. Therefore, each mapper will get sufficient input to process, which

(11)

increases performance to a great extent and job completion time is expected to reduce at least by half. Beside this it involves slight overhead as each mapper process multiple files and eats lots of memory in the Namenode.

5.Conclusion

Currently Hadoop Distributed File System (HDFS) facing problem with small files. Various methods have been proposed to deal with this problem. Based on some common parameters, it could be seen that CombineFileInputFormat gives best performance in terms of overhead as it involves slight overhead by combining multiple files into single split compare to other methods where sending each file to a map-reduce task will cause too much overhead. It also increases reading efficiency of small files to a great extent.

Acknowledgements

I take this opportunity to express my profound gratitude and deep regards to my guide Prof. Mrs.Rajashree Shedge for her exemplary guidance, monitoring and constant encouragement throughout the completion of this research paper. I am truly grateful to her efforts to improve my technical writing skills. The blessing, help and guidance given by her time to time shall carry me a long way in the journey of life on which I am about to embark. I take this privilege to express my sincere thanks to Dr. Mr.Ramesh Vasappanavara, Principal, RAIT for providing the much necessary facilities.

I am also thankful to Dr. Mrs.Leena Ragha, Head of Department of Computer Engineering and PG Co-ordinator Prof. Mrs.Vanita Mane, Department of Computer Engineering, RAIT, for their generous support.

Last but not the least I would also like to thank all those who have directly or indirectly helped me in completion of this research paper.

References

1. Dave, P. Learning Basics of Big Data in 21 Days. Retrieved Nov 26, 2014, available at http://blog.sqlauthority.com/2013/10/30/big-data learning-basics-of-big-data-in-21-days-\\bookmark/

2. Bappalige, S.P. An introduction to Apache Hadoop for big data. Retrieved Nov 27, 2014, available at http://opensource.com/life/14/8/intro-apache-hadoop-big-data

3. Maniyam, S., Kerzner, M. Hadoop illuminated} (1st Ed.). Houston: Hadoop Illuminated LLC., 2013.

4. Panchal, B., Gohil, P., “Efficient Ways to Improve the Performance of HDFS for Small Files”, Computer Engineering and Intelligent Systems, Vol.5, pp.45-49, August 2014.

5. Palmer, B., “Hadoop: Strengths and Limitations in National Security Missions”, SAP National Security Services, June 2012. 6. Beal, V. HDFS. Retrieved Nov 27, 2014, available at http://www.webopedia.com/TERM/H/hadoop_distributed_file_system_hdfs.html. 7. Chansler, R., Kuang, H., Radia, S., and Shvachko, K., The Architecture of Open Source Applications} (1st ed.). Brea: aosabook, (2013). 8. Korat, V.G., Pamu, K.S., “Reduction of Data at Namenode in HDFS using HAR Technique”, International Journal of Advanced Research in

Computer Engineering and Technology, Vol.1, pp.635-642, June 2012.

9. Chen, J., Wang, D., Fu, L., and Zhao, W., “An Improved Small File Processing Method for HDFS”, International Journal of Digital Content Technology and its Applications (JDCTA), Vol.6, pp.296-304, Nov 2012.

10. Gurav, Y.B., Jayakar, K.P., “Efficient Way for Handling Small Files using Extended HDFS”, International Journal of Computer Science and Mobile Computing, Vol.3, pp.785-789, June 2014.

(12)

11. Nupairoj, N., Vorapongkitipun, Chatuporn., “Improving Performance of Small-File Accessing in Hadoop”, 11th International Joint Conference on Computer Science and Software Engineering, pp.200-205, May 2014.

12. Dr. Raut, S., Phakade, P., “An Innovative Strategy for Improved Processing of Small Files in Hadoop” International Journal of Application or Innovation in Engineering and Management, Vol.3, pp. 278-280, July 2014.

References

Related documents

With all of the change in health care and the unprecedented demand for physician leadership, this book is a must-have for every physician with an interest in medical

Even at this early stage, Duke was getting noticed for his different style of music and by 1930, Duke and his band were famous..

Het opstellen van de overeenkomst van huwelijkse voorwaarden voor- afgaand of tijdens het huwelijk heeft immers tot gevolg dat de door de wet in Titel 7 van Boek 1 Burgerlijk

Objectives: The main objective of the study is to measure the impact of microvascular complications and to assess the effect of patient counselling in im- proving

• Prior to joining Whitman Howard, Araminta was a buy-side analyst with a specialist small and mid-cap

In the following section, information on the VDR variants found in the populations of South Africa was collated, with the aim of determining the function of such polymorphisms

– Text data in files, databases or stored in the Hadoop Distributed File System (HDFS) – Dataset will not fit into memory. 

•  Hadoop Distributed File System (HDFS™): A distributed file system that provides high- throughput access to application data.. •  Hadoop YARN: A framework for job scheduling