Spark性能调优

Spark性能调优

executor内存不足

  1. 问题表现1:Container xx is running beyond physical memory limits. Current usage: xxx GB of x GB physical memory used; xx GB of x GB virtual memory used...
    原因:这个报错显而易见,数据使用的内存超过了这个executor分配的内存
  2. 问题表现2:长时间的 Fail to get RpcResponse: Timeout,最后会报heartbeat心跳检测失败而任务失败
    原因:实际上同样是因为内存不足,导致GC而超时,最终失败

解决:

1 首先可以尝试开大executor的内存分配

2 如果配置的内存无法满足数据内存,可以尝试:

2.1 增加大数据量位置的repartition数

scala 复制代码
   val allDf = sourceDf
      .repartition(5000)
      .flatMap(row => { }).toDF()

2.2 增加spark session的超时时间

scala 复制代码
    val ss = SparkSession.builder()
      .config("spark.sql.shuffle.partitions", 1000)
      .config("spark.driver.maxResultSize", "20g")
      .config("hive.exec.dynamic.partition", true)
      .config("hive.exec.dynamic.partition.mode", "nonstrict")
      .config("hive.exec.parallel", true)
      .config("mapred.max.split.size", 64000000)
      .config("mapred.min.split.size.per.node", 64000000)
      .config("mapred.min.split.size.per.rack", 64000000)
      .config("hive.exec.reducers.bytes.per.reducer", 256000000)
      .config("hive.exec.reducers.max", 2000)
      .config("hive.merge.mapredfiles", true)
      .config("hive.merge.smallfiles.avgsize", 128000000)
      .config("hive.merge.size.per.task", 128000000)
      .config("spark.yarn.executor.memoryOverhead", "10g")
      .config("spark.network.timeout", 10000000)	// 调大
      .enableHiveSupport()
      .getOrCreate()

UNION ALL代替UNION

UNION会默认对两个表的结果进行去重,如果没有去重的需要,就使用UNION ALL,速度会更快

persist与耗时监控

在主流程的对运算结果调用处persist,并打点进行耗时监控。而不是在运算方法内部persist,便于看清每一步的运算时间。

相关推荐
SelectDB8 小时前
秒级弹性、最高降本 70%:SelectDB Serverless 如何重塑云数仓资源效率
大数据·后端·云原生
WhoAmI8 小时前
MapReduce框架原理解析一:InputFormat
大数据·hadoop
WhoAmI8 小时前
MapReduce框架原理解析三:OutputFormat
大数据·hadoop
WhoAmI8 小时前
MapReduce框架原理解析二:Shuffle
大数据·hadoop
大大大大晴天1 天前
Hudi技术内幕:Key Generation原理与实践
大数据
得物技术5 天前
从埋点需求到规则资产:Hermes Agent 重构得物数仓工作流
大数据·llm·ai编程
久美子5 天前
AI驱动数仓建设的Harness工程实践——本体建模、知识分层与上下文工程
大数据
大树885 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
大志哥1235 天前
ES和Logstash日志链路系统上线后遭遇切片爆炸(解决)
大数据·elasticsearch
果丁智能5 天前
物联网智能锁赋能集中式住宿:身份核验与远程权限管控的全链路技术实践
大数据·人工智能·物联网·智能家居