Hi, I am investigating akka-http as a potential replacement for spray for our new microservices. There we have lots of blocking IO operations that are pretty easy to handle with spray by wrapping them in Future and blocking and providing a separate thread pool.
I tried to test the same approach with simple Akka HTTP code: object Main extends App with SimpleAkkaHttpMain with Logging trait SimpleAkkaHttpMain { implicit val system: ActorSystem = ActorSystem() implicit def executor: ExecutionContextExecutor = system.dispatcher val endpointDispatcher = system.dispatchers.lookup("akka.dispatchers.threadpool-dispatcher") implicit val materializer: Materializer = ActorMaterializer() Http().bindAndHandle(new SimpleEndpoint(endpointDispatcher).routes(), "0.0.0.0", 9000) } class SimpleEndpoint(_context: ExecutionContext) extends Directives { implicit val context = _context def routes() = { (get & path("test")) { complete { Future { blocking { Thread.sleep(2000) } "test" } } } } } Config: threadpool-dispatcher { type = Dispatcher executor = "thread-pool-executor" thread-pool-executor { core-pool-size-min = 2 core-pool-size-factor = 2.0 core-pool-size-max = 100 } } I ran the following terminal command to test it: > ab -n 50 -c 4 http://localhost:9000/test Benchmarking localhost (be patient)...apr_socket_recv: Connection reset by peer (54) Total of 10 requests completed This is what I see in logs: history-api DEBUG [2015-07-05 15:24:11,403 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:11,404 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:13,426 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:13,426 CEST] SelectionHandler - Monitored actor [Actor[akka://default/system/IO-TCP-STREAM/server-1-%2F0.0.0.0%3A9000/$A#-1737469294]] terminated history-api DEBUG [2015-07-05 15:24:13,427 CEST] SelectionHandler - Monitored actor [Actor[akka://default/system/IO-TCP-STREAM/server-1-%2F0.0.0.0%3A9000/$z#-1452647390]] terminated history-api DEBUG [2015-07-05 15:24:16,186 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:16,186 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:16,187 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:16,187 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:18,202 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:18,208 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:18,208 CEST] SelectionHandler - Monitored actor [Actor[akka://default/system/IO-TCP-STREAM/server-1-%2F0.0.0.0%3A9000/$F#1453413388]] terminated history-api DEBUG [2015-07-05 15:24:18,209 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:18,209 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:20,217 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:20,219 CEST] TcpListener - New connection accepted history-api DEBUG [2015-07-05 15:24:20,223 CEST] SelectionHandler - Monitored actor [Actor[akka://default/system/IO-TCP-STREAM/server-1-%2F0.0.0.0%3A9000/$K#1142842464]] terminated A similar test for Spray works smoothly. Can you please help me with advice what one can do to process blocking operations in akka-http? -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.