Here are some useful resources on how to tune Spark job in terms of number of executors, executor memory and number of cores.
http://blog.cloudera.com/blog/2015/03/how-to-tune-your-apache-spark-jobs-part-2/
https://aranair.github.io/posts/2017/03/10/tuning-my-apache-spark-cluster-on-aws-emr/