Multiple SparkSessions in single JVM
<p>I have a query regarding creating multiple spark sessions in one JVM. I have read that creating multiple contexts is not recommended in earlier versions of Spark. Is it true with the SparkSession in Spark 2.0 as well.</p>

<p>I am thinking of making a call to a web service or a servlet from the UI, and the service creates a spark session, performs some operation and returns the result. This will result in a spark session being created for every request from the client side. Is this practice recommended ?</p>

<p>Say I have a method something like :</p>

<p>public  void runSpark() throws Exception {</p>

<pre><code>        SparkSession spark = SparkSession
          .builder()
          .master("spark://&lt;masterURL&gt;")
          .appName("JavaWordCount")
          .getOrCreate();
</code></pre>

<p>and so on....</p>

<p>If I put this method in a web service , will there be any JVM issues ? As such I am able invoke this method multiple times from a main method.But not sure if this is good practice.</p>