multithreading - Configuring maximum number of threads in Akka Http does not work as expected -


i'm trying test application akka-http, receives json sent post , stuff them. i'm trying rise max number of threads http route can handle. test put thread.sleep in basic route. i'm expecting route handle @ "parallelism-max" post requests until blocks because of lack of threads.

let me explain following example:

when program starts, create actorsystem using following code:

system = actorsystem("foo", configfactory.load()) 

i define implicit materializer (type actormaterializer):

implicit lazy val materializer: actormaterializer = actormaterializer(actormaterializer().settings.withdispatcher("akka.actor.dispatcher-fork")) 

and create own dispatcher in order control number of threads way:

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"       }     }   } } 

and work data:

val basicroute =    post{     complete {       logger.info("hey: " + thread.currentthread().getid)       thread sleep 60000 //let threads sleep see how many of them can have       statuscodes.accepted -> none // body none     }   } 

this status of log:

      starting akka...   running akka 2.4.1    info  c.t.b.app.app$ listening on 0.0.0.0:2554   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 

nothing happens if send more post requests until of threads wake , finish processing.

i've tried change parameters:

parallelism-min = 2 parallelism-max = 20 

to these:

parallelism-min = 1 parallelism-max = 2 

it works expected (takes 2 messages until blocks).

why in first case doesn't work?

thanks in advance help.

ps: these version i'm using:

akka version = 2.4.1 akka stream , http version = 2.0.2 

and resources checked:

http://doc.akka.io/docs/akka/current/scala/dispatchers.html http://doc.akka.io/docs/akka/current/general/configuration.html

edit: cpu used intel® core™ i7-4790s cpu @ 3.20ghz × 8, 4 physical cores using hyperthreading (8 logical ones).


Comments