title: Execution Context and Dispatcher - Best practices, useful configurations and Documentation
body: <h1>Scala Execution Context and Dispatchers - Listing and comparison: Why ?</h1>
  
  <p>There are a lot of questions around what/how/what is the best <code>Execution Context</code> to use to execute futures on in Scala and how to configure the dispatcher.
  Still I never was able to find a longer list with pros and cons and configuration  examples.</p>
  
  <p>The best I could find was in the Akka Documentation: <a href="http://doc.akka.io/docs/akka/snapshot/scala/dispatchers.html" rel="noreferrer">http://doc.akka.io/docs/akka/snapshot/scala/dispatchers.html</a> and Play Documentation <a href="https://www.playframework.com/documentation/2.5.x/ThreadPools" rel="noreferrer">https://www.playframework.com/documentation/2.5.x/ThreadPools</a>.</p>
  
  <p>I would like to ask what configurations besides the <code>scala.concurrent.ExecutionContext.Implicits.global</code> and Akka defaults you use in your daily Dev lives, when you use them and what are the pros and cons .</p>
  
  <p>Here are some of the ones I already have:</p>
  
  <h1>First unfinished overview</h1>
  
  <h2>Standard: <code>scala.concurrent.ExecutionContext.Implicits.global</code></h2>
  
  <ul>
  <li><p>use when unsure</p></li>
  <li><p>Easy to use</p></li>
  <li>shared for everything</li>
  <li><p>may use up all your CPU</p></li>
  <li><p>more Info: <a href="http://www.scala-lang.org/api/2.11.5/index.html#scala.concurrent.ExecutionContext" rel="noreferrer">http://www.scala-lang.org/api/2.11.5/index.html#scala.concurrent.ExecutionContext</a></p></li>
  </ul>
  
  <h2>Testing - <code>ExecutionContext.fromExecutor(new ForkJoinPool(1))</code></h2>
  
  <ul>
  <li>use for testing</li>
  <li>no parallelism</li>
  </ul>
  
  <h2>Play's default EC - <code>play.api.libs.concurrent.Execution.Implicits._</code></h2>
  
  <ul>
  <li>use instead of <code>scala.concurrent.ExecutionContext.Implicits.global</code> when using Play</li>
  <li>Play default</li>
  <li><p>shared</p></li>
  <li><p>more Info: <a href="https://www.playframework.com/documentation/2.5.x/ThreadPools" rel="noreferrer">https://www.playframework.com/documentation/2.5.x/ThreadPools</a></p></li>
  </ul>
  
  <h2>Akka`s default Execution Context</h2>
  
  <ul>
  <li><p>based on configuration</p></li>
  <li><p>more Info: <a href="http://doc.akka.io/docs/akka/snapshot/scala/dispatchers.html" rel="noreferrer">http://doc.akka.io/docs/akka/snapshot/scala/dispatchers.html</a></p></li>
  </ul>
  
  <h2>Bulkheading</h2>
  
  <pre><code>ExecutionContext.fromExecutor(new ForkJoinPool(n)) based on an separated dispatcher . Thanks to Sergiy Prydatchenko
  </code></pre>