Reviewed by Aditya Kumar · Last reviewed 2026-03-24
The small file problem in Spark refers to the significant performance degradation and resource inefficiencies caused by processing and storing data in a large number of very small files (kilobytes to…
Red Flag: Suggesting coalesce without considering partition count or downstream consumers. Pro-Move: 'We added OPTIMIZE + Z-ORDER on Delta after each streaming batch; file count dropped from 50K to 500, queries 5x faster'—shows Delta fluency.
This hard-level Spark/Big Data question appears frequently in data engineering interviews at companies like Daniel Wellington, Incedo, Swiggy. While less common, it tests deeper understanding that distinguishes strong candidates. Mastering the underlying concepts (partition, spark) will help you answer variations of this question confidently.
This is a senior-level question that tests architectural thinking. Lead with the high-level design, then drill into specifics. Discuss trade-offs explicitly - there is rarely one correct answer. Show awareness of scale, fault tolerance, and operational complexity. The expert answer includes a code example that demonstrates the implementation pattern.
The small-file problem in Spark refers to the significant performance degradation and resource inefficiencies caused by processing and storing data in a large number of very small files (kilobytes to a few megabytes each). This leads to substantial overhead in metadata management, task scheduling, and I/O operations, particularly in distributed file systems like HDFS or object storage like S3.
LIST operations are rate-limited and incur costs. HDFS NameNodes also struggle with memory for excessive metadata. Common root causes include high parallelism (e.g., spark.sql.shuffle.partitions set too high), over-partitioning data using df.write.partitionBy() on high-cardinality columns, and frequent micro-batch writes in streaming applications.
df.coalesce(num_partitions) or df.repartition(num_partitions) before writing. coalesce avoids a full shuffle if reducing partitions. df.repartition(200).write.parquet("s3://my-bucket/path")
OPTIMIZE commands (e.g., OPTIMIZE table_name ZORDER BY column_name) for compaction and auto-compaction features that merge small files in the background, managing metadata efficiently through a transaction log.spark.sql.shuffle.partitions to control output file count. For reading, spark.sql.files.maxPartitionBytes groups small files into larger input partitions.While larger files improve read performance and reduce overhead, excessively large files can hinder parallelism (fewer tasks) and make granular updates or deletions less efficient. Optimal file size balances these factors.
In the interview, also mention the direct impact on cloud storage costs (S3 LIST/GET requests) and how managed data warehousing solutions like Snowflake abstract this away through their micro-partitioning and clustering mechanisms.
Red Flag: Suggesting coalesce without considering partition count or downstream consumers. Pro-Move: 'We added OPTIMIZE + Z-ORDER on Delta after each streaming batch; file count dropped from 50K to 500, queries 5x faster'—shows Delta fluency.
Practice the 66 most asked data engineering questions at Swiggy. Covers SQL, Spark/Big Data, Python/Coding and more.
13 min read →Senior Spark interviews at Amazon, Databricks, and Meta focus on performance tuning, not API syntax. Master these 15 questions to prove you've run Spark at scale.
20 min read →Some links below are affiliate links. If you buy through them we may earn a small commission at no extra cost to you — it helps keep DataEngPrep free.
According to DataEngPrep.tech, this is one of the most frequently asked Spark/Big Data interview questions, reported at 3 companies. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.