EMR 上 Hadoop 作业的 S3 文件的最佳文件大小?

Optimal File Size of S3 Files for Hadoop Job on EMR?

我正在尝试确定存储在 S3 中的文件的理想大小,该文件将用于 EMR 上的 Hadoop 作业。

目前我有大约 5-10gb 的大文本文件。我担心将这些大文件复制到 HDFS 到 运行 MapReduce 作业的延迟。我可以选择缩小这些文件。

我知道在 MapReduce 作业中使用 S3 作为输入目录时,S3 文件会并行复制到 HDFS。但是,是使用单线程将单个大文件复制到 HDFS,还是将该文件作为多个部分并行复制?另外,Gzip 压缩是否影响将单个文件分成多个部分复制?

有两个因素需要考虑:

  • 压缩文件不能在任务之间拆分。例如,如果您有一个大型压缩输入文件,则只有一个 Mapper 可以读取它。
  • 使用 更多、更小的文件 使并行处理更容易,但在为每个文件启动 Map/Reduce 作业时会有 更多的开销文件。因此,文件越少速度越快。

因此,在文件的大小和数量之间存在权衡。推荐尺寸列在几个地方:

Amazon EMR FAQ推荐:

If you are using GZIP, keep your file size to 1–2 GB because GZIP files cannot be split.

Best Practices for Amazon EMR whitepaper推荐:

That means that a single mapper (a single thread) is responsible for fetching the data from Amazon S3. Since a single thread is limited to how much data it can pull from Amazon S3 at any given time (throughput), the process of reading the entire file from Amazon S3 into the mapper becomes the bottleneck in your data processing workflow. On the other hand, if your data files can be split, more than a single mapper can process your file. The suitable size for such data files is between 2 GB and 4 GB.

主要目标是在不引入太多开销的情况下,通过并行处理尽可能多的文件来保持所有节点忙碌。

哦,继续使用压缩。磁盘 space 和数据传输时间的节省使其比启用拆分更有优势。