Shuffling in spark is (as per my understanding):
I have a question about this:
Spark shuffle outputs are always written to disk.
Why ? because simply you cannot send data from an executor memory to another executor memory directly, it has to be written locally than loaded into the executor memory, that's why you have serialization deserialization during shuffling, that's why having a quality disks (ssd) is also important for spark.
from blog.scottlogic.com
During a shuffle, data is written to disk and transferred across the network, halting Spark’s ability to do processing in-memory and causing a performance bottleneck.