系统与基础设施aadrake.com编辑精选
命令行工具可能比你的 Hadoop 集群更快
Command-line tools can be faster than your Hadoop cluster
2015 — 2016,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
作者用一组具体的命令行管线(grep、awk、sort、xargs 等)在单机处理约 3.5GB 的数据,并把它和跑在 Hadoop 集群上的同类任务做对比,结果显示命令行快了约 235 倍。文章借此说明:数据量还装得进内存和单机磁盘时,分布式框架往往是杀鸡用牛刀。
为什么经久不衰:它用一个可复现的基准把“大数据工具被滥用”这一长期问题讲得很直白,提醒人们先估算数据规模、再选工具,这个道理今天依然成立。
HN 评论精选
用 xargs 并行 grep 会导致行内容交错,输出不可靠。
我认为像文中那样用 xargs 并行跑 grep 是不安全的:除了输出顺序会乱,多个 grep 的输出还可能互相交错——一行的开头来自一个 grep、结尾来自另一个 grep,之后逐行读取就会得到乱码行。参见 GNU parallel 手册中关于 xargs 与 parallel 差异的说明。
a3_nm查看英文原文
I think it is unsafe to parallelize grep with xargs as in done in the article, because, beyond delivery order shuffling, the output of the parallel greps could get mixed up (the beginning of a line is by one grep and the end of a line is from a different grep, so, reading line by line afterwards, you get garbled lines). See https://www.gnu.org/software/parallel/man.html#DIFFERENCES-BETWEEN-xargs-AND-GNU-Parallel
有学术论文系统性地证明:很多分布式系统的性能还不如单机。
这个想法曾是一篇系统领域顶会论文的主题,叫《Scalability! But at what cost?》。它不止于这个简单例子,还进一步考察了大多数系统论文的成果其实能被一台笔记本打败。这里是论文和介绍博文。
deadgrey19查看英文原文
This idea was the subject of a paper at a major systems conference. The paper is called "Scalability! But at what cost?" - It goes well beyond this simple example above to explore how most major systems papers produce results that can be beaten by a single laptop. Here's the paper and the blog post describing it. http://www.frankmcsherry.org/assets/COST.pdf http://www.frankmcsherry.org/graph/scalability/cost/2015/01/15/COST.html
统一生态带来的运维、容错和集成收益,可能超过手写命令行管线的成本。
我觉得每次这类话题出现,人们都完全忽略了“把尽可能多的数据处理任务放在同一套生态里”的好处。我们很多作业处理的数据量在低 TB 级并持续增长;但即便某个作业的数据非常小,我也会用 Hadoop(如今是 Spark)来写,因为构建、部署和调度都由现有系统免费搞定。当然,启动时花在 S3 上列文件的时间比跑作业本身还长是浪费,但远小于自建并维护一套定制数据转换的人力成本。这些工具的主要好处其实不是规模或处理速度,而是容错、故障恢复、弹性,以及社区提供的海量聚合、数据类型和外部集成生态。
vlahmot查看英文原文
I feel like every time something like this comes up people completely skip over the benefit of having as much of your data processing jobs in one ecosystem as possible. Many of our jobs operate on low TBs and growing but even if the data for a job is super small I'll write it in Hadoop (Spark these days) so that the build, deployment, and schedluing of the job is handled for free by our curent system. Sure spending more time listing files on S3 at startup than running the job is a waste but far less than the man hours to build and maintain a custom data transformation. The main benefit of these tools is not the scale or processing speed though. The main benefits are the fault tolerance, failure recovery, elasticity, and the massive ecosystem of aggregations, data types and external integrations provided by the community.
作者回应:Hadoop 被滥用的现实确实普遍,甚至有人用它处理不到 1MB 的数据。
大家好,我是原文作者。有人质疑我为什么花时间反对用 Hadoop 处理这么小的数据任务——那本来就不该用它。遗憾的是,大数据(Big Data™)框架被推荐、被要求使用、被过度使用的频率远超应有水平。我知道在我们很多人看来这很荒唐,但这是真的。我见过最离谱的是用 Hadoop 处理不到 1MB 的任务。说真的。另外,我非常赞同应该加大命令行工具的教育投入,O'Reilly 甚至出了一本相关的书。感谢大家的评论和支持。
aadrake查看英文原文
Hi all, original author here. Some have questioned why I would spend the time advocating against the use of Hadoop for such small data processing tasks as that's clearly not when it should be used anyway. Sadly, Big Data (tm) frameworks are often recommended, required, or used more often than they should be. I know to many of us it seems crazy, but it's true. The worst I've seen was Hadoop used for a processing task of less than 1MB. Seriously. Also, much agreement with those saying there should be more education effort when it comes to teaching command line tools. O'Reilly even has a book out on the topic: http://shop.oreilly.com/product/0636920032823.do Thank you for all the comments and support.
历次讨论
同类还值得读
TTY 揭秘(2008)
The TTY demystified (2008)
经典文章深入剖析了 Unix/Linux 中 TTY 子系统的工作原理,包括线路规程、终端驱动、信号与控制字符等机制。
系统与基础设施上首页 11 次 · 2009–2025linusakesson.net编辑精选为什么 GNU grep 这么快
Why GNU grep is Fast
FreeBSD 邮件列表上一篇广为流传的帖子,解释 GNU grep 为什么快:核心在于 Boyer-Moore 字符串搜索算法配合精心优化的内部循环和 I/O,让程序在搜索时“…
系统与基础设施上首页 9 次 · 2010–2022lists.freebsd.orgXplain:为普通人讲解 X11
Xplain – Explaining X11 for the rest of us
《Xplain》是作者(HN 用户 Jasper_)写的一系列 X11 长文,用他在浏览器中重建的 X11 绘图模型做交互演示,讲解 X11 的绘图模型与窗口系统设计。
系统与基础设施上首页 6 次 · 2013–2020magcius.github.io编辑精选旋风教程:为 Linux 创建极小 ELF 可执行文件(1999)
A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux (1999)
breadbox 写于 1999 年的经典教程,主题是如何为 Linux 手工构造并裁剪出体积极小的 ELF 可执行文件。
系统与基础设施上首页 6 次 · 2007–2025muppetlabs.comPostgreSQL 内部原理
The internals of PostgreSQL
《The Internals of PostgreSQL》是一本免费在线书籍,系统讲解 PostgreSQL 的内部实现,包括查询处理、并发控制、WAL、缓冲区管理等核心机制。
系统与基础设施上首页 5 次 · 2017–2025interdb.jp编辑精选