独立处理大量小文件

时间:2015-05-11 06:21:47

标签: hadoop amazon-web-services amazon-ec2 mapreduce elastic-map-reduce

任务是独立处理HUGE(大约10,000,000)个小文件(每个大约1MB)(即处理文件F1的结果,与处理F2的结果无关)。

有人为我的任务建议使用Map-Reduce(在Amazon-EMR Hadoop上)。但是,我对MR有严重怀疑。

原因是在我的情况下处理文件是独立的。据我所知,当输出依赖于许多单个文件(for example counting the frequency of each word, given many documents时,它最有效,因为输入文件中的任何文档中都可能包含一个单词)。但就我而言,我只需要很多独立的CPU /核心。

我想知道你是否对此有任何建议。

附注:还有一个问题是MR最适合“大文件而不是大量小尺寸”。 Although there seems to be solutions for that.所以我暂时无视它。

2 个答案:

答案 0 :(得分:1)

可以根据您的需要使用map reduce。在MapReduce中,有两个阶段MapReduce,但reduce阶段不是必须的,只为了您的情况,您可以编写map-only MapReduce作业,并且应该将单个文件上的所有计算放入自定义的Map函数中。

但是,我没有在一个作业中处理如此庞大数量的文件,也不知道它的效率。亲自尝试,与我们分享:)

答案 1 :(得分:1)

This is quite easy to do. In such cases - the data for MR job is typically the list of files (and not the files themselves). So the size of the data submitted to Hadoop is the size of 10M file names - which is order of a couple of gigs max.

One uses MR to split up the list of files into smaller fragments (how many can be controlled by various options). Then each mapper gets a list of files. It can process one file at a time and generate the output.

(fwiw - I would suggest Qubole (where I am a founder) instead of EMR cause it would save you a ton of money with auto-scaling and spot integration).