title: How to know which piece of code runs on driver or executor?
body: <p>I am new to Spark. How to know which piece of code will run on the driver &amp; which will run on the executors ?</p>
  
  <p>Do we always have to try to code such that everything runs on the executors ?. Is there any recommendations/ways to make most of your code to run on executors ?</p>
  
  <p>Update: I far as I understand Transformations run on executors &amp; actions runs on driver because it needs to return value. So is it fine if the action runs on driver or should it also run on executor ? Where does the driver actually run ? on cluster ?</p>