Repository navigation
performance
David Liu edited this page Mar 31, 2025
·
3 revisions
结果表明,在Databricks中,Parquet(默认格式)的数据处理速度比ORC快
- Prewarm clusters
- by using Databricks Pool
- target: reduce cluster start and auto-scaling times
- Prewarm caches
- by running specific queries to initialize caches
- Specifying schema on flat file(e.g. csv) can improve dataframe read query performance
- Define how to join
- by
df.hint({broadcast/merge})[TODO] -
SortMerge: used to large data volume (larger thanspark.sql.autoBroadcastJoinThreshold) -
BroadcastHash: used for small data volume.- reason: smaller tables are transferred to every executor on the worker nodes, and cached locally in memory, and thus avoid data shuffle between the nodes
- by
- Partition: trade-off between parallelism and data shuffles
- Default partition block size is 128 MB
- configure by
spark.conf.set("spark.sql.files.maxPartitionBytes", 1048576)(for 1MB here)
- configure by
- Partition within a dataframe
- When the data is small, then the number of partitions should be reduced
- view created partitions count by
df.rdd.getNumPartitions() - update by
df.repartition(target_partitions_count).- Expensive operation: It involves fully shuffling the data
- update by
df.coalesce(minimum_partitions_count)- cheaper: It only moves data from redundant nodes
- global setting for data shuffling trigger by transform (e.g. join(), union())
spark.conf.set("spark.sql.shuffle.partitions", target_partitions)
- Default partition block size is 128 MB
Reduce only df.coalesce({number of partitions}), which usually runs faster because executor leaves data in a minimum number of partitions and only moves data from redundant nodes Control the number of output files by df.write.option("maxRecordsPerFile", {number of files e.g. 1000}) Sets the the number of partitions to use during data shuffling, which is triggered by data transformations such as join(), union(), groupByKey(), reduceBykey(), and so on. spark.conf.set("spark.sql.shuffle.partitions", {number of partitions})
- TPC-DS v2.4 (1000 scale factor)
- aws machine
- 44 vcpu, 336 GB memory
- 11 r3.xlarge (1 driver, 10 workers)
- Databricks Runtime 3.0
Sample datasets
- Databricks recommended 3rd party CSV
samplescatalog-
databricks-datasets: native sample datasets in DBFS- mounted path:
/databricks-datasets
- mounted path: