Home › Interview Questions › Suppose you have a Spark job with four executors a…

Suppose you have a Spark job with four executors and you want to perform a broadcast join. How do you decide the size threshold for the small table to be broadcasted?

🟡 Medium Conceptual Mid level
1Times asked
Oct 2026Last seen
Oct 2026First seen

💡 Model Answer

Spark automatically decides whether to broadcast a table based on the configuration spark.sql.autoBroadcastJoinThreshold, which defaults to 10 MB. To determine the appropriate threshold for a small table when you have four executors, you should consider the memory available per executor and the total memory budget. For example, if each executor has 8 GB of heap, you might set the threshold to 50 MB to avoid spilling. You can tune this by running a dry‑run with spark.sql.autoBroadcastJoinThreshold set to a higher value and monitoring the executor memory usage. Additionally, you can use the broadcast hint in the query (e.g., broadcast(table)) to force a broadcast regardless of size. Remember to also set spark.sql.broadcastTimeout to a higher value if the broadcast takes longer. In practice, a good rule of thumb is to keep the broadcast size below 10–20 % of the executor memory, so for 8 GB executors you might set the threshold to 800–1 GB. This balances the cost of shuffling versus the cost of broadcasting.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500