I've been wondering about this while working with larger datasets in Spark
When a job starts taking longer than expected, the easiest solution seems to be adding more workers or increasing the cluster size. But that also increases the cost, and I'm not always sure whether the job actually needs more resources or whether the code itself is the problem.
For example, a job might run fine with a few million records but become painfully slow when the data grows. Sometimes adding workers helps, but other times the improvement is barely noticeable.
How do you guys figure out what's actually causing the bottleneck?
A few things I'm curious about:
Do you check the Spark Ul first? If so, which metrics do you usually look at?
How do you identify whether a job is suffering from data skew, excessive shuffling, or too many small partitions?
When do you increase executor memory, and when is that just masking the real problem?
Have you had cases where adding more workers actually made a job slower?
How do you decide between scaling up, scaling out, and optimizing joins or transformations?
In Databricks, do you rely on autoscaling, or do you prefer to tune the cluster based on the workload?
I'm particularly interested in what happens with jobs that process hundreds of millions of records, where even a small inefficiency can make a big difference to runtime and cost.
I know the answer depends on the workload, but what's the first thing you investigate before deciding to throw more compute at a slow spark job?
Would be great to hear how you approach this in real projects, especially if You've dealt with a job that kept getting more expensive without getting much faster.