Spark 2.2.0 FileOutputCommitter

user3279189 picture user3279189 · Sep 17, 2017 · Viewed 7.5k times · Source

DirectFileOutputCommitter is no longer available in Spark 2.2.0. This means writing to S3 takes insanely long time (3 hours vs 2 mins). I'm able to work around this by setting FileOutputCommitter version to 2 in spark-shell by doing this,

spark-shell --conf spark.hadoop.mapreduce.fileoutputcommitter.algorithm.version=2 

same does not work with spark-sql

spark-sql --conf spark.hadoop.mapreduce.fileoutputcommitter.algorithm.version=2 

The above command seems to be setting the version=2 but when the query is exeucted it still shows version 1 behaviour.

Two questions,

1) How do I get FileOutputCommitter version 2 behaviour with spark-sql?

2) Is there a way I can still use DirectFileOutputCommitter in spark 2.2.0? [I'm fine with non-zero chance of missing data]

Related items:

Spark 1.6 DirectFileOutputCommitter

Answer

Avishek Bhattacharya picture Avishek Bhattacharya · Sep 17, 2017

I have been hit by this issue. Spark is discouraging the usage of DirectFileOutputCommitter as it might lead to data loss in case of race situation. The algorithm version 2 doesn't help a lot.

I have tried to use the gzip to save the data in s3 instead of snappy compression which gave some benefit.

The real issue here is that spark writes in the s3://<output_directory>/_temporary/0 first then copies the data from temporary to the output. This process is pretty slow in s3,(Generally 6MBPS) So if you get lot of data you will get considerable slowdown.

The alternative is to write to HDFS first then use distcp / s3distcp to copy the data to s3.

Also , You could look for a solution Netflix provided.

I haven't evaluated that.

EDIT:

The new spark2.4 version has solved the problem of slow s3 write. I have found the s3 write performance of spark2.4 with hadoop 2.8 in the latest EMR version (5.24) is almost at par with HDFS write.

See the documents

  1. https://aws.amazon.com/blogs/big-data/improve-apache-spark-write-performance-on-apache-parquet-formats-with-the-emrfs-s3-optimized-committer/

  2. https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-spark-s3-performance.html