Inside Apache Spark
summary
Explains why PySpark can be slow: Python UDFs either become per-element Py4J calls or require serialized byte arrays, causing heavy JVM↔Python shuffling and socket overhead. Describes Spark’s two dependency types (one-to-one and shuffle dependency) and shows that joins/groupBy trigger expensive network shuffles; recommends concrete fixes such as using reduceByKey with combiners instead of groupByKey, batching work with mapPartitions or pipe, and using Spark 2.3’s Apache Arrow / vectorized Pandas UDFs to run pandas-like code inside partitions and greatly reduce serialization cost.
AI-written summary · about
