title: scala, spray, akka - java.lang.OutOfMemoryError: unable to create new native thread
body: <p>While checking the throughput of spray api.</p>
  
  <p>Scenario: 25 concurrent users</p>
  
  <p>Os: Free BSD</p>
  
  <p>Memory: 2GB</p>
  
  <p>No Of Cores: 2</p>
  
  <p>At around 13 concurrent users i was getting the following error.</p>
  
  <pre><code>[ERROR] [06/29/2015 05:01:56.407] [default-akka.actor.default-dispatcher-2]     [ActorSystem(default)] Uncaught error from thread [default-akka.actor.default-dispatcher-2] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled
  java.lang.OutOfMemoryError: unable to create new native thread
      at java.lang.Thread.start0(Native Method)
      at java.lang.Thread.start(Thread.java:714)
      at scala.concurrent.forkjoin.ForkJoinPool.tryAddWorker(ForkJoinPool.java:1672)
      at scala.concurrent.forkjoin.ForkJoinPool.deregisterWorker(ForkJoinPool.java:1795)
      at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:117)
  </code></pre>
  
  <p>Akka and Spray Conf changes from default:</p>
  
  <pre><code>akka{
      tcp{
          register-timeout = 20s
      }
  }
  
  spray.can {
      request-timeout = 30 s
      bind-timeout = 30s
      unbind-timeout = 5s
      registration-timeout = 30s
  }
  
  http.spray.can {
      server{
          pipelining-limit = 50
      }
  }
  </code></pre>
  
  <p>What is causing the OutOfMemmoryError. The exception is thrown from the <strong>router actor</strong> </p>