【发布时间】:2021-06-22 08:54:18
【问题描述】:
我们需要从非分区EXTERNAL配置单元表work_db.customer_tbl中提取数据到通过 PySpark 的分区 EXTERNAL hive 表 final_db.customer_tbl,之前通过 hive 查询完成。最终表由 load_date 列进行分区(load_date 列的格式为 yyyy-MM-dd)。
所以我们有一个简单的 PySpark 脚本,它使用插入查询(与之前使用的 hive 查询相同),使用 spark.sql()获取数据> 命令。但是我们有一些严重的性能问题,因为我们在摄取后尝试摄取的表有大约 3000 个分区,每个分区都有大约 4 MB 的数据,除了最后一个分区大约是4GB。总表大小接近 15GB。此外,在摄取后,每个分区都有 217 个文件。决赛桌是一张简洁的压缩拼花桌。
源工作表有一个 15 GB 文件,文件名格式为 customers_tbl_unload.dat。
早些时候,当我们通过直线连接使用 hive 查询时,通常需要大约 25-30 分钟才能完成。现在,当我们尝试使用 PySpark 脚本时,大约需要 3 个小时才能完成。
我们如何调整火花性能以使摄取时间少于直线所需的时间。
The configurations of the yarn queue we use is:
Used Resources: <memory:5117184, vCores:627>
Demand Resources: <memory:5120000, vCores:1000>
AM Used Resources: <memory:163072, vCores:45>
AM Max Resources: <memory:2560000, vCores:500>
Num Active Applications: 45
Num Pending Applications: 45
Min Resources: <memory:0, vCores:0>
Max Resources: <memory:5120000, vCores:1000>
Reserved Resources: <memory:0, vCores:0>
Max Running Applications: 200
Steady Fair Share: <memory:5120000, vCores:474>
Instantaneous Fair Share: <memory:5120000, vCores:1000>
Preemptable: true
The parameters passed to the PySpark script is:
num-executors=50
executor-cores=5
executor-memory=10GB
PySpark code used:
insert_stmt = """INSERT INTO final_db.customers_tbl PARTITION(load_date)
SELECT col_1,col_2,...,load_date FROM work_db.customer_tbl"""
spark.sql(insert_stmt)
即使在几乎使用了纱线队列的 10% 资源之后,这项工作也花费了很多时间。我们如何调整工作以提高效率。
【问题讨论】:
标签: apache-spark pyspark hive apache-spark-sql