Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I take advantage of my local resources using Spark in local mode?

I've been using Apache Spark to write a desktop app which lets you tamper data interactively. I've recently started reading "Learning Spark" and in that the author says that in local mode (when master is set to local) Spark only uses one Thread.

How can I take advantage of all of the cores in my computer without having a full-blown Spark cluster on my computer?

I'm using Java / Kotlin.

like image 609
Adam Arold Avatar asked Dec 20 '25 15:12

Adam Arold


1 Answers

It defaults to one, but you can specify how many you'd like like so:

 val config = SparkConfig()
 config.setMaster("local[8]") // local, using 8 threads (you can vary the number)
 config.setAppName("qwerty")
 val context = SparkContext(config)
like image 84
hudsonb Avatar answered Dec 22 '25 04:12

hudsonb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!