Spark Dynamic Allocation

How Dynamic Allocation of Executors works in spark and how to effectively use it in spark job