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,便于看清每一步的运算时间。

相关推荐
那就学有所成吧(˵¯͒¯͒˵)2 小时前
大数据项目(一):Hadoop 云网盘管理系统开发实践
大数据·hadoop·分布式
KKKlucifer3 小时前
数据资产地图构建:文档安全可视化与主动防御
大数据·安全
2501_943695334 小时前
高职工业大数据应用专业,怎么找智能制造企业的数据岗?
大数据·信息可视化·制造
得赢科技4 小时前
智能菜谱研发公司推荐 适配中小型餐饮
大数据·运维·人工智能
Hello.Reader5 小时前
Flink 内存与资源调优从 Process Memory 到 Fine-Grained Resource Management
大数据·flink
有代理ip5 小时前
成功请求的密码:HTTP 2 开头响应码深度解析
java·大数据·python·算法·php
jl48638215 小时前
打造医疗设备的“可靠视窗”:医用控温仪专用屏从抗菌设计到EMC兼容的全链路解析
大数据·运维·人工智能·物联网·人机交互
刺客xs6 小时前
git 入门常用命令
大数据·git·elasticsearch
risc1234566 小时前
【Elasticsearch】LeafDocLookup 详述
大数据·elasticsearch·mybatis
qq_12498707536 小时前
基于协同过滤算法的运动场馆服务平台设计与实现(源码+论文+部署+安装)
java·大数据·数据库·人工智能·spring boot·毕业设计·计算机毕业设计