I'm using Spark on EMR. I launch a cluster and sometimes the cluster is small (when writing/testing out code), say 5-10 instances. Other times executing the same code using a larger number of instances say 30-50.
I know I can access the configurations to assist in setting the number of partitions and choosing a good number of partitions helps the runtime.
I'd like to parameterize the number of partitions as a function of the number of executors and the number of threads:
val instanceCount = sc.getConf.get("spark.executor.instances").toDouble
val coreCount = sc.getConf.get("spark.executor.cores").toDouble
Has anyone looked into this and can give any advice on a good way to parametrize the number of partitions?
I realize there will not be one good answer but some functional form, with constants would help. For example:
val partitionCount = instanceCount*coreCount*0.7
appears to work good in my use cases and describe your use cases (number/range of executors) that would be helpful.
In the answer if you could indicate the range of instances your working over that would be helpful too. If there is a canonical investigation of this somewhere a pointer to that would be helpful.