gpt4 book ai didi

apache-spark - Spark Elasticsearch基本调整

转载 作者:行者123 更新时间:2023-12-03 02:32:40 25 4
gpt4 key购买 nike

如何设置 Spark 以提高速度?

我正在运行spark-elasticsearch来分析日志数据。

与200万行(4gig)进行聚合/合并大约需要5分钟。

我正在3台计算机上运行1个主机,3个 worker 。
我将执行程序的内存增加到8g,将ES节点从1增加到3。

我正在客户端模式(https://becominghuman.ai/real-world-python-workloads-on-spark-standalone-clusters-2246346c7040)中运行独立集群
我不使用spark-submit,只是在启动master / workers之后运行python代码

Spark似乎总共推出了3个执行者(来自3个 worker )。

我想稍微调整一下 Spark 以在不做任何调整的情况下获得最佳性能。

我应该采取哪种方式进行优化?

  1. consider other cluster (yarn, etc .. although I have no idea what they offer, but it seems it's easier to change memory related settings there)
  2. run more executors
  3. analyze the job plan with explain api
  4. accept it takes that much time because you have to download 4gig data (should spark grap all data to run aggregate? such as group by and sum), if applicable, save the data to parquet (?) for further analysis


以下是与我的表现相关的设置
 conf.set("es.scroll.size", 10000)
conf.set("spark.executor.memory", "8g")
conf.set("spark.driver.memory", "8g")
conf.set("spark.dynamicAllocation.enabled", "true")
conf.set("spark.shuffle.service.enabled", "true")
conf.set("es.nodes.resolve.hostname", "false")
conf.set("spark.driver.extraClassPath", "/usr/local/elasticsearch-hadoop-7.4.2/dist/elasticsearch-spark-20_2.11-7.4.2.jar")
conf.set("es.nodes", settings.ES_HOST)
conf.set("es.nodes.wan.only", 'true')

spark-defaults.conf
 # https://becominghuman.ai/real-world-python-workloads-on-spark-standalone-clusters-2246346c7040
spark.sql.execution.arrow.enabled true

# https://spark.apache.org/docs/latest/job-scheduling.html#dynamic-resource-allocation
spark.dynamicAllocation.enabled true
spark.shuffle.service.enabled true

最佳答案

这并不总是内存或群集配置的问题,我建议先尝试在增加内存之前尝试优化正在运行的查询/聚合。

您可以在此处找到Spark Performance Tuning的一些提示。另请参见Tuning Spark。确保查询是最佳的,并避免表现为UDF的性能下降。

对于群集中的执行程序和内存配置,您必须考虑所有计算机上的可用内存和内核以计算适当的参数。这是关于最佳做法的intersting post

关于apache-spark - Spark Elasticsearch基本调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59590216/

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