【问题标题】:Hive tips for reducing 100 % Cpu utilization on amazon EMR用于降低亚马逊 EMR 上 100% Cpu 利用率的 Hive 技巧
【发布时间】:2018-06-04 07:24:41
【问题描述】:

我正在使用下表来处理大约 15GB(.gz 压缩)的 iislog。 使用亚马逊 EMR(1 个中型主实例、4 个大型核心实例、2 个任务实例)。甚至需要大约 1 小时才能获得此查询的结果:

select uri, cs_Cookie as Cookie, count(*) as hits from tmp1 group by cs_Cookie, uri order by hits Desc;

我看到所有 DataNode 上的 cpu 利用率每次都是 100%。那么,有人可以建议如何减少查询时间和cpu利用率吗?

表定义:

create external table marData(logdate string, time string, computername string, clientip string, uri string, qs string, localfile string, status string, referer string, w3status string, sc_bytes string, cs_bytes string, w3wpbytes string, cs_username string, cs_user_agent string, time_local string, timetakenms string, sc_substatus string, s_sitename string, s_ip string, s_port string, RequestsPerSecond string, s_proxy string, cs_version string, c_protocol string, cs_method string, cs_Host string, EndRequest_UTC string, date_local string, CPU_Utilization string, cs_Cookie string, BeginRequest_UTC string) partitioned by (month string) ROW FORMAT SERDE
'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
               WITH SERDEPROPERTIES (
               "input.regex" ="([0-9-]+) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) (\".*\"|[^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) (\".*\"|[^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) (\".*\"|[^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([0-9-]+ [0-9:.]+) ([^ ]*) ([^ ]*) (\".*\"|[^ ]*) ([0-9-]+ [0-9:.]+)",
               "output.format.string"="%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s %10$s %11$s %12$s %13$s %14$s %15$s %16$s %17$s %18$s %19$s %20$s %21$s %22$s %23$s %24$s %25$s %26$s %27$s %28$s %29$s %30$s %31$s %32$s")
location 's3://logdata/Mar';

【问题讨论】:

  • 为什么这是一件坏事? 100% CPU 意味着你的集群很忙,这很好,如果你低于 100% 意味着你没有充分利用你的集群。
  • 我正在搜索为什么我的集群没有得到充分利用。我希望它是 100%

标签: amazon-web-services hadoop hive amazon-emr


【解决方案1】:

查询期间节点的内存使用情况如何?

正如@Charles Menguy 在 cmets 中所说,高 CPU 使用率本质上并不是一件坏事。

您可以考虑使用更多、更大的节点在更短的时间内完成工作。这可能需要一些实验,但这对您来说甚至可能更便宜。例如,我们发现与最初使用更多 m1.large 实例相比,切换到更大的节点(我们使用 m2.xlarge)可以让我们的工作每美元运行得更快。

【讨论】:

  • 谢谢大家的建议。我还有一个查询,我目前正在使用 REGEX 来解析日志数据,正如您在表定义中看到的那样。 Regex 内部使用 Hash 表来解析数据并消耗大量内存。我可以用更好的方式来做吗?
猜你喜欢
  • 2012-12-15
  • 2020-08-05
  • 1970-01-01
  • 1970-01-01
  • 2019-02-04
  • 1970-01-01
  • 1970-01-01
  • 2013-02-07
  • 1970-01-01
相关资源
最近更新 更多