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

相关推荐
bubble小拾3 小时前
ElasticSearch高级功能详解与读写性能调优
大数据·elasticsearch·搜索引擎
ZOHO项目管理软件3 小时前
EDM平台大比拼 用户体验与营销效果双重测评
大数据
weixin_453965003 小时前
[单master节点k8s部署]31.ceph分布式存储(二)
分布式·ceph·kubernetes
坎坎坷坷.3 小时前
分布式理论:拜占庭将军问题
分布式
HyperAI超神经4 小时前
Meta 首个多模态大模型一键启动!首个多针刺绣数据集上线,含超 30k 张图片
大数据·人工智能·深度学习·机器学习·语言模型·大模型·数据集
Hello.Reader6 小时前
TopK算法在大数据重复数据分析中的应用与挑战
大数据·算法·数据分析
数据龙傲天6 小时前
1688商品API接口:电商数据自动化的新引擎
java·大数据·sql·mysql
Elastic 中国社区官方博客6 小时前
Elasticsearch:使用 LLM 实现传统搜索自动化
大数据·人工智能·elasticsearch·搜索引擎·ai·自动化·全文检索
Jason不在家8 小时前
Flink 本地 idea 调试开启 WebUI
大数据·flink·intellij-idea
Elastic 中国社区官方博客9 小时前
使用 Vertex AI Gemini 模型和 Elasticsearch Playground 快速创建 RAG 应用程序
大数据·人工智能·elasticsearch·搜索引擎·全文检索