Configuring the Number of Tasks for Spark to Read ORC and Parquet Files
Scenarios
When Spark reads ORC and Parquet files, you can control the number of reading tasks by specifying the value of SplitBytes and compression ratio. This feature prevents reading tasks for ORC and Parquet files from increasing with the number of available Executors, thereby reducing invalid tasks, relieving scheduling pressure of Driver tasks, and improving overall performance of Driver in heavy-load scenarios.
Notes and Constraints
- This section applies only to MRS 3.6.0-LTS.1 and later.
- Supported table types: DataSource tables, ORC Hive tables (supported when spark.sql.hive.convertMetastoreOrc is set to true), and Parquet Hive tables (supported when spark.sql.hive.convertMetastoreParquet is set to true)
- Supported data formats: Parquet and ORC
Configuring Parameters
Modify the following parameters in the {Client installation directory}/Spark/spark/conf/spark-defaults.conf file on the Spark client.
| Parameter | Parameters | Default Value |
|---|---|---|
| spark.sql.orc.resourceFriendly.split.mode.enabled | Whether to use SplitBytes and compression rate to control the number of reading tasks when Spark reads ORC files.
| false |
| spark.sql.preset.orc.stripe.size | Recommended value of orc.stripe.size for Spark to read ORC files | 64 MB |
| spark.sql.orc.fileCompressionFactor | Size of the compressed stripe in the ORC file/Value of orc.stripe.size. The size of the compressed stripe in the ORC file varies depending on data. | 1.0 |
| spark.sql.parquet.resourceFriendly.split.mode.enabled | Whether to use SplitBytes and compression rate to control the number of reading tasks when Spark reads Parquet files.
| false |
| spark.sql.preset.parquet.block.size | Recommended value of parquet.block.size for Spark to read Parquet files | 128 MB |
| spark.sql.parquet.fileCompressionFactor | Size of the compressed row group in the Parquet file/Value of parquet.block.size. The size of the compressed row group in the Parquet file varies depending on the data. | 1.0 |
Calculation Logic of SplitBytes During File Reading
- In the case of insufficient available resources, the files are split based on the value of SplitBytes calculated according to the available resources.
- When spark.sql.orc.resourceFriendly.split.mode.enabled is set to true, the value of SplitBytes is calculated as follows during ORC file reading:
orcStripSize = spark.sql.preset.orc.stripe.size * spark.sql.orc.fileCompressionFactor
The final value of SplitBytes = Math.max (SplitBytes calculated based on available resources, orcStripSize)
- When spark.sql.parquet.resourceFriendly.split.mode.enabled is set to true, the value of SplitBytes is calculated as follows during Parquet file reading:
parquetBlockSize = spark.sql.preset.parquet.block.size * spark.sql.parquet.fileCompressionFactor
The final value of SplitBytes = Math.max (SplitBytes calculated based on available resources, parquetBlockSize)
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot