gpt4 book ai didi

hadoop - HDFS 和 MapReduce 如何处理小文件

转载 作者:可可西里 更新时间:2023-11-01 14:35:00 26 4
gpt4 key购买 nike

我已经在 Windows 平台上安装了 Hadoop 和 2 个其他工作节点(我总共有 3 个节点)。出于演示目的,我正在处理大约 1 兆字节的单个文件。

  1. 工作节点如何划分此文件以进行处理。不同的工作节点每个会处理 341(1024/3)KB。或者单个工作节点将处理该文件。

  2. 如果我处理 100 个这样的文件。工作节点会分配要处理的文件数量吗?

  3. 如果我处理一个大约 100MB 的文件。

最佳答案

可能的答案,

How worker nodes would divide this file for processing. Would different worker nodes would process 341(1024/3)KB each. Or a single worker node would process the file?

与 Windows 中可用的 NTFS 和 FAT 等普通文件系统相比,Hadoop 分布式文件系统 (HDFS) 通常具有更大的 block 大小。 HDFS 中的 block 通过复制分散在多个节点(机器)上,如果提供了机架拓扑脚本,则可以更好地处理复制,并且更有策略地放置 block 以防止数据丢失(例如,如果 Hadoop 在不知不觉中将复制因子为 2 的 block 放置在同一个机架和整个机架发生故障,哎呀!。一个好的策略可能是将一个 block 存储在一个机架中,而将其他复制的 block 存储在不同的机架中)。默认情况下,一个 block 的大小为 64MB。因此,一个 1 MB 的文件可能会驻留在一个单独的 block 中,当然,也会跨不同的节点进行复制。通常单个 Map 工作在称为拆分的东西上,它可以由一个或多个 block 组成。可以有不同 map 可以处理的拆分。 TextInputFormat通常处理以尾行作为分隔符的文本文件,并为每个拆分触发映射,这大致是一个 block 的大小。为确保端线边界,拆分大小可能略大于或小于 block 大小。最重要的是,在正常情况下驻留在单个 64MB block 中的 1 MB 文件将由单个 map 任务处理。

And if I process 100 such files. Would worker nodes divide the number of files to be processed among them?

如果有 100 个单独的此类文件,则可能会调用 100 个 map task ,除非您使用类似 CombineInputFormat 的东西可以将多个 block 合并并处理在一起作为 map 的拆分。

另一个选择是尽可能将这 100 个文件合并到一个文件和进程中。

And if I process a single file of about 100MB?

同样,假设您的 block 大小为 64MB,一个 TextInputFormat 的 100MB 文件应该大致由 2 个 map task 处理。正如我所说,不同的 InputFormat 可以用不同的方式处理事情!

注意(摘自here):

Speculative execution: One problem with the Hadoop system is that by dividing the tasks across many nodes, it is possible for a few slow nodes to rate-limit the rest of the program. For example if one node has a slow disk controller, then it may be reading its input at only 10% the speed of all the other nodes. So when 99 map tasks are already complete, the system is still waiting for the final map task to check in, which takes much longer than all the other nodes.

By forcing tasks to run in isolation from one another, individual tasks do not know where their inputs come from. Tasks trust the Hadoop platform to just deliver the appropriate input. Therefore, the same input can be processed multiple times in parallel, to exploit differences in machine capabilities. As most of the tasks in a job are coming to a close, the Hadoop platform will schedule redundant copies of the remaining tasks across several nodes which do not have other work to perform. This process is known as speculative execution. When tasks complete, they announce this fact to the JobTracker. Whichever copy of a task finishes first becomes the definitive copy. If other copies were executing speculatively, Hadoop tells the TaskTrackers to abandon the tasks and discard their outputs.

关于hadoop - HDFS 和 MapReduce 如何处理小文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18046453/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com