Configuring maximum number of threads in Akka Http does not work as expected
<p>I'm trying to test my application with akka-http, which receives some json sent by POST and do some stuff with them. I'm trying to rise the max number of threads that my http route can handle. To test this I put a Thread.sleep in a basic route. What I'm expecting is that the route handle at most "parallelism-max" POST requests until it blocks because of the lack of threads.</p>

<p>Let me explain with the following example:</p>

<p>When my program starts, I create the ActorSystem using the following code:</p>

<pre><code>system = ActorSystem("foo", ConfigFactory.load())
</code></pre>

<p>I define my implicit materializer (type ActorMaterializer):</p>

<pre><code>implicit lazy val materializer: ActorMaterializer = ActorMaterializer(ActorMaterializer().settings.withDispatcher("akka.actor.dispatcher-fork"))
</code></pre>

<p>And I create my own dispatcher in order to control the number of threads this way:</p>

<pre><code>akka {
  actor {
    dispatcher-fork {
      type = "Dispatcher"
      executor = "default-executor"
      default-executor {
        fallback = "fork-join-executor"
      }
      fork-join-executor {
        parallelism-min = 2
        parallelism-factor = 3.0
        parallelism-max = 20
        task-peeking-mode = "FIFO"
      }
    }
  }
}
</code></pre>

<p>And I work with my data:</p>

<pre><code>val basicRoute = 
  post{
    complete {
      logger.info("hey: " + Thread.currentThread().getId)
      Thread sleep 60000 //Let the threads sleep to see how many of them I can have
      StatusCodes.Accepted -&gt; None // Body none
    }
  }
</code></pre>

<p>This is the status of the log:</p>

<pre><code>      Starting Akka...
  Running Akka 2.4.1
   INFO  c.t.b.app.App$ Listening on 0.0.0.0:2554
  Successfully started Akka
   INFO  c.t.b.app.App$ hey: 70
   INFO  c.t.b.app.App$ hey: 73
   INFO  c.t.b.app.App$ hey: 75
   INFO  c.t.b.app.App$ hey: 72
   INFO  c.t.b.app.App$ hey: 77
   INFO  c.t.b.app.App$ hey: 74
</code></pre>

<p>Nothing happens if I send more POST requests until some of my Threads wake up and finish its processing.</p>

<p>I've tried to change this parameters:  </p>

<pre><code>parallelism-min = 2
parallelism-max = 20
</code></pre>

<p>to these:   </p>

<pre><code>parallelism-min = 1
parallelism-max = 2
</code></pre>

<p>it works as expected (takes only 2 messages until blocks). </p>

<p>Why in the first case doesn't work? </p>

<p>Thanks in advance for your help.</p>

<p>PS: These are the version I'm using:</p>

<pre><code>Akka Version = 2.4.1
Akka Stream And Http Version = 2.0.2
</code></pre>

<p>And the resources that I already checked:</p>

<p><a href="http://doc.akka.io/docs/akka/current/scala/dispatchers.html" rel="nofollow">http://doc.akka.io/docs/akka/current/scala/dispatchers.html</a>
 <a href="http://doc.akka.io/docs/akka/current/general/configuration.html" rel="nofollow">http://doc.akka.io/docs/akka/current/general/configuration.html</a></p>

<p>Edit:
The CPU used is a Intel® Core™ i7-4790S CPU @ 3.20GHz × 8, so 4 physical cores using hyperthreading (8 logical ones).</p>