Spark on YARN allows Spark jobs to run efficiently on YARN clusters. It supports two modes: yarn-client mode where the driver runs locally, and yarn-cluster mode where the driver runs in a YARN container. Dynamic resource allocation allows Spark to dynamically allocate containers based on workload, launching and killing executors as needed. This improves resource utilization by avoiding inefficient allocation where containers remain unused after tasks complete. Configuration changes are required to enable the external shuffle service to store RDD state externally rather than within executors.